Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

SetEnv PERL5LIB in htaccess for Apache 2.2 versus 1.3

by monkfan (Curate)
on Jul 03, 2007 at 05:00 UTC ( #624593=perlquestion: print w/ replies, xml ) Need Help??
monkfan has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,
Running this piece of code is never a problem in Apache 1.3.
#!/usr/bin/perl use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); $CGI::POST_MAX=1024 * 100; # max 100K posts1 BEGIN { if ( $ENV{PERL5LIB} and $ENV{PERL5LIB} =~ /^(.*)$/ ) { # Blindly untaint. Taintchecking is to protect # from Web data; # the environment is under our control. eval "use lib '$_';" foreach ( reverse split( /:/, $1 ) ); } } use Acme::Spork; use Bio::Tools::GuessSeqFormat; print "Content-type: text/html\n\n"; print "Hello World !! It works.\n";
It can recognize the path as set in .htaccess below:
SetEnv PERL5LIB /home/monkfan/lib/perl5/site_perl/5.8.5/i386-linux-th +read-multi:/home/monkfan/lib/perl5/site_perl/5.8.5
Then I upgraded from Apache 1.3 to 2.2 on the same Linux box. But now with Apache 2.2, it can't locate the location of those modules as set in the identical htaccess.

Does anybody has experience of setting PERL5LIB for htaccess in Apache 2.2? How can I resolve the problem above?

Regards,
Edward

Comment on SetEnv PERL5LIB in htaccess for Apache 2.2 versus 1.3
Select or Download Code
Re: SetEnv PERL5LIB in htaccess for Apache 2.2 versus 1.3
by Anonymous Monk on Jul 03, 2007 at 05:50 UTC
    But now with Apache 2.2, it can't locate the location of those modules as set in the identical htaccess.
    It sounds (from the error message) like you need to go learn about Apache 2.2.
Re: SetEnv PERL5LIB in htaccess for Apache 2.2 versus 1.3
by graq (Curate) on Jul 03, 2007 at 07:53 UTC

    This will depend on on other settings in your Apache configuration. Under some circumstances PERL5LIB is ignored.

    My personal preference for when additional library directories are required, is to define them under a different variable and incorporate that into a wrapping class. This stops me polluting the core perl variables, and it clearly shows the purpose.

    -=( Graq )=-

      ... define them under a different variable and incorporate that into a wrapping class. This stops me polluting the core perl variables, and it clearly shows the purpose.

      Can you give example, how you do that?

      Regards,
      Edward
        Here's what I suggest:

        Somewhere in you apache config file, add something like this (the exact path can vary, of course):

        PerlRequire /var/www/perl/startup.pl

        Then create startup.pl so that it looks like this:

        use lib qw(/path/to/my/modules); use MY::MODULE; 1;

        The use lib line adds directories to the search path. If you actually put use MY::MODULE in the startup file, these modules will be preloaded when apache starts up.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2014-09-18 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (101 votes), past polls