SetEnv should work fine as long as your server has mod_env enabled. If not, there are other ways to set environment variables in Apache.

In the unlikely case that $HOME actually exists, it will most likely be useless since it would probably refer to ~apache and not ~you. I suppose that mod_suexec might be able to make it your $HOME again, but that's a lot of work for little gain.

You might have a problem with permissions. For Apache to be able to read your files, you have to grant permissions for others to read. Maybe it's as simple as chmod o+x perl5lib. You can check if Apache can read the dir with a simple cgi that includes something like

#!/usr/bin/perl -T print "Content-type: text/plain\n\n"; print "PERL5LIB is $ENV{PERL5LIB}\n" -X $ENV{PERL5LIB} and print "Apache can read $ENV{PERL5LIB}\n";

If all else fails, use lib should do the trick, so I'd bet on a permissions problem.

Update: made script useable.

In reply to Re: apache2 passing PERL5LIB environment to cgi by rowdog
in thread apache2 passing PERL5LIB environment to cgi by debinix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.