Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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

Replies are listed 'Best First'.
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.

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.

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?
[holli]: You see, I have a friend whose daughter has been damaged seriously because she wasn't vaccinated against measles. (Her mother being anti-vaxx).
[LanX]: Contrary to Olivia newton John I don't like physical confrontations ...
[LanX]: Oh, you spread measles in your saliva?
[LanX]: ... and why did you bite hos daughter?
[LanX]: *his
[holli]: And this guy was also Anti-Vaxx and I just snapped. I shoed him all over the yard
[james28909]: biting between the legs? now thats my kind of religion.
[holli]: and back into the building, saw him later peeking out of the window looking scared. It was hilarious.
[LanX]: Let's get physical...
[james28909]: wish i could stay and chat. i have an unsuspecting client to give an estimate to. muhhahaha

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-12-13 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?