Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

mod_perl, PerlSetEnv, and PERL5LIB

by geektron (Curate)
on Jul 27, 2004 at 17:54 UTC ( #377801=perlquestion: print w/replies, xml ) Need Help??
geektron has asked for the wisdom of the Perl Monks concerning the following question:

this should be easy. i've created a subclass of Apache::AuthCookie, and now i'm trying to enable it.

this is a virtual-hosting setup, with each VH having a conf. file. in order to enable Apache::AuthCookieDBI (which is also running on this machine) correctly, i also have a specific modperl include for that domain. i created another one like it for the new, Apache::AuthCookie authentication.

it's really basic:

PerlSetVar PERL5LIB /home/httpd/ PerlModule RemoteAuthentication PerlSetVar ProImagePath / PerlSetVar ProImageLoginScript /apps/
attempting to use the script kicks out a 500 error, and the error log says RemoteAuthentication can't be found ... even though, via an Include, this PERL5LIB is being set in the main httpd.conf ...

is there that much of a difference between a strictly Perl-based use lib and setting  PERL5LIB in mod_perl?

Replies are listed 'Best First'.
Re: mod_perl, PerlSetEnv, and PERL5LIB
by Joost (Canon) on Jul 27, 2004 at 18:57 UTC
    is there that much of a difference between a strictly Perl-based use lib and setting PERL5LIB in mod_perl?
    Mostly, that perl only reads $ENV{PERL5LIB} when it's started:
    use lib '/some/dir'; use Module;
    will work as expected, while
    BEGIN { $ENV{PERL5LIB} = "/some/dir:$ENV{PERL5LIB}"; } use Module;
    will not, if is in /some/dir.

    Either use lib or BEGIN { unshift @INC }, but you have to do both from perl; you can't use PERL5LIB, as perl is already running before apache starts reading the config files.

Re: mod_perl, PerlSetEnv, and PERL5LIB
by tinita (Parson) on Jul 28, 2004 at 08:29 UTC
    PerlSetVar PERL5LIB /home/httpd/
    uhm, i think this is the wrong way to set an environment variable. as the docs say, variables set by PerlSetVar are only available to the apache API: mod_perl

    so just use PerlSetEnv, as you did in the title of this node...

      well, i changed the (that's loaded by the main httpd.conf via Include this morning to read as such:
      PerlSetEnv PERL5LIB /home/httpd/ PerlModule RemoteAuthentication PerlSetVar websitePath /testMemberArea/ PerlSetVar websiteLoginScript /apps/ PerlSetVar websiteDomain PerlSetVar websiteExpires +1h
      and the VH.conf to read:
      ## These documents require user to be logged in. <Directory /home/httpd/> AuthType RemoteAuthentication AuthName website PerlAuthenHandler RemoteAuthentication->authenticate PerlAuthzHandler RemoteAuthentication->authorize require valid-user </Directory>
      and that looks right to me, but i still get:
      sudo /usr/sbin/apachectl configtest Syntax error on line 7 of /etc/httpd/conf/VH/ Can't locate in @INC (@INC contains: /usr/lib/ +perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/per +l5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5 +.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-l +inux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/ven +dor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/ +5.8.0 . /usr/ /usr/lib/perl) at (eval 7) line 3.
      i've tried things like:
      PerlSetEnv PERL5LIB PERL5LIB:/home/httpd/
      to no avail ...
        hmm, sorry, i thought it would work... (googling for it also suggests it should). anyway, i'd go for the alternative, that's a common thing to do with mod_perl.
Re: mod_perl, PerlSetEnv, and PERL5LIB
by johnnywang (Priest) on Jul 27, 2004 at 19:50 UTC
    I usually use a startup script for mod_perl where I do "use lib". i.e., put something like the following in httpd.conf:
    PerlRequire "/var/www/cgi-bin/"
    Then in, I add:
    use lib qw(/path_to_your_lib); use Apache::Log(); use Apache::DBI(); # and any other module you want to load
      well, i got the auth module loading, but now apache is ignoring the ProImagePath directive.

      i've looked at the cookie on a successful login, and the Path is set to /apps (the aliased dir for, and not to  / (or any of the other variants i've tried.

      grrr ..

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://377801]
Approved by NovMonk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2017-04-23 06:19 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (430 votes). Check out past polls.