Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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/website.com/libs PerlModule RemoteAuthentication PerlSetVar ProImagePath / PerlSetVar ProImageLoginScript /apps/login.pl
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?

Comment on mod_perl, PerlSetEnv, and PERL5LIB
Select or Download Code
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 Module.pm 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 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/mod_perl_startup.pl"
    Then in mod_perl_startup.pl, 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 login.pl), and not to  / (or any of the other variants i've tried.

      grrr ..

Re: mod_perl, PerlSetEnv, and PERL5LIB
by tinita (Parson) on Jul 28, 2004 at 08:29 UTC
    PerlSetVar PERL5LIB /home/httpd/website.com/libs
    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 modperl.site.conf (that's loaded by the main httpd.conf via Include this morning to read as such:
      PerlSetEnv PERL5LIB /home/httpd/website.com/libs PerlModule RemoteAuthentication PerlSetVar websitePath /testMemberArea/ PerlSetVar websiteLoginScript /apps/login.pl PerlSetVar websiteDomain .website.com PerlSetVar websiteExpires +1h
      and the VH.conf to read:
      ## These documents require user to be logged in. <Directory /home/httpd/website.com/html/testMemberArea> 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/modperl.website.com: Can't locate RemoteAuthentication.pm 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/website.com/libs
      to no avail ...
        hmm, sorry, i thought it would work... (googling for it also suggests it should). anyway, i'd go for the startup.pl alternative, that's a common thing to do with mod_perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://377801]
Approved by NovMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-08-31 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls