You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tim Sweetman <ti...@aldigital.co.uk> on 2001/04/10 17:33:08 UTC

@INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Hi,

According to this document,

http://thingy.kcilink.com/modperlguide/porting/_INC_and_mod_perl.html

you can add directories to @INC by putting

PerlSetEnv PERL5LIB /home/httpd/perl

in your Apache conf. file (that is unless you're using taint checking,
in which case it will be ignored...?)

Not using taint checking, and with Apache 1.3.12, mod_Perl 1.24, I find
that this behaves exactly the same as SetEnv PERL5LIB, ie. works for the
first page request, after which @INC reverts to its state without the
directories listed in SetEnv.

A previous approach, which does appear to work, is to set PERL5LIB
*before* starting Apache

ie. PERL5LIB=/usr/lib/foo httpsd ...

Can anyone shed any light on this?

Thanks in advance,

--
Tim Sweetman
A L Digital
"Who knows where the Tim goes?" --- Fairport Convention

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by Roger Espel Llima <ro...@iagora.net>.
I Told You So <ti...@aldigital.co.uk> wrote:
> I'd also appreciate knowing if the "set the env. variable before
> Apache run" approach (ie. PERL5LIB=/usr/lib/foo httpsd ...) works,
> or whether this is going to be blown out of the water by
> subsequent mod_perl versions (though this may be currently
> unknowable, or known by very few people).  :)

It works for me at least.  I'm PERL5LIB to keep several versions of
mod_perl's modules on the same system; the first one I installed
(mod_perl 1.21) installed itself under the default location
(/usr/lib/perl5/site_perl/Apache), and then when I needed to setup 
another Apache with a more recent mod_perl, I prepared it with

perl Makefile.PL APACHE_SRC=../apache_1.3.19/src DO_HTTPD=1 USE_APACI=1 \
                  PREP_HTTPD=1 EVERYTHING=1 \
		  LIB=/usr/local/new-apache/perl-lib

and then I added the line
   PERL5LIB=/usr/local/ssl-apache/perl-lib ; export PERL5LIB
to /usr/local/new-apache/bin/apachectl

Looking at /perl-status's Modules page, @INC looks good.

-- 
Roger Espel Llima, roger@iagora.net
http://www.iagora.com/~espel/index.html

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by I Told You So <ti...@aldigital.co.uk>.
> Vivek Khera wrote:
> >
> > >>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:
> >
> > TS> you can add directories to @INC by putting
> >
> > TS> PerlSetEnv PERL5LIB /home/httpd/perl

Thanks Vivek, but I was after clarification of whether this was a bug
(to be fixed) or inaccurate docs (also to be fixed). I'd also appreciate
knowing if the "set the env. variable before Apache run"
approach (ie. PERL5LIB=/usr/lib/foo httpsd ...) works, or whether this
is going to be blown out of the water by subsequent mod_perl versions
(though this may be currently unknowable, or known by very few people).
:)

On a related note (preloading in startup scripts), presumably packages
which use AutoLoader/SelfLoader will do a fairly half-baked job of
preloading. Should this pair have some kind of compile() functionality?
(Not saying I'd implement it, but IF we turn out to need it, and nobody
else has, and people think it's a good idea...)

Cheers

--
Tim Sweetman
A L Digital

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by "Keith G. Murphy" <ke...@mindspring.com>.
Stas Bekman wrote:
> 
> On Wed, 11 Apr 2001, Keith G. Murphy wrote:
> 
> > Vivek Khera wrote:
> > >
> > > >>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:
> > >
> > > TS> you can add directories to @INC by putting
> > >
> > > TS> PerlSetEnv PERL5LIB /home/httpd/perl
> > >
> > > Just use the second method in the guide.  ie, use lib '/path/to/lib'
> > > in a startup script.
> > >
> > I request that the guide be changed, since apparently the 'PerlSetEnv'
> > way hasn't worked properly for some time.  Never has for me, anyway.
> 
> Do you have the taint mode turned on? I think at some point mod_perl
> ignores PERL5LIB settings then. Can you confirm that?
> 
Ah, I just noticed something else.  If I *am* running a startup script
that 'use's modules that are in my PERL5LIB, I must do 'use lib', or the
script fails to load them.  So 'PerlSetEnv PERL5LIB' is  pretty much
useless (because not sufficient and redundant to 'use lib') in this
case.

That's probably normal and to-be-expected, but it would be nice if it
were actually documented.

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by "Keith G. Murphy" <ke...@mindspring.com>.
Stas Bekman wrote:
> 
> On Wed, 11 Apr 2001, Keith G. Murphy wrote:
> 
> > Vivek Khera wrote:
> > >
> > > >>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:
> > >
> > > TS> you can add directories to @INC by putting
> > >
> > > TS> PerlSetEnv PERL5LIB /home/httpd/perl
> > >
> > > Just use the second method in the guide.  ie, use lib '/path/to/lib'
> > > in a startup script.
> > >
> > I request that the guide be changed, since apparently the 'PerlSetEnv'
> > way hasn't worked properly for some time.  Never has for me, anyway.
> 
> Do you have the taint mode turned on? I think at some point mod_perl
> ignores PERL5LIB settings then. Can you confirm that?
> 
It seems to be working like a charm for me now.  :-)
I regret the false imputation...
The root of my misunderstanding was that I did not realize that when I
would start apache by hand, it was getting PERL5LIB from my shell
environment.
Then, when the system would reboot, and start Apache, it didn't have it!
So I probably just had things misconfigured (like using 'SetEnv' instead
of 'PerlSetEnv'), and mistakenly concluded that 'use lib' was the only
thing that works reliably.
I could never really debug the problem properly, since everything always
worked by hand.
Then when I saw Tim's post, it seemed to confirm what I already thought
I knew.
Shows what assuming will do.  Hee-haw.  ;-)

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by Stas Bekman <st...@stason.org>.
On Wed, 11 Apr 2001, Keith G. Murphy wrote:

> Vivek Khera wrote:
> >
> > >>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:
> >
> > TS> you can add directories to @INC by putting
> >
> > TS> PerlSetEnv PERL5LIB /home/httpd/perl
> >
> > Just use the second method in the guide.  ie, use lib '/path/to/lib'
> > in a startup script.
> >
> I request that the guide be changed, since apparently the 'PerlSetEnv'
> way hasn't worked properly for some time.  Never has for me, anyway.

Do you have the taint mode turned on? I think at some point mod_perl
ignores PERL5LIB settings then. Can you confirm that?


_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by "Keith G. Murphy" <ke...@mindspring.com>.
Vivek Khera wrote:
> 
> >>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:
> 
> TS> you can add directories to @INC by putting
> 
> TS> PerlSetEnv PERL5LIB /home/httpd/perl
> 
> Just use the second method in the guide.  ie, use lib '/path/to/lib'
> in a startup script.
> 
I request that the guide be changed, since apparently the 'PerlSetEnv'
way hasn't worked properly for some time.  Never has for me, anyway.

Re: @INC and mod_perl - PerlSetEnv PERL5LIB ... doesn't seem to work

Posted by Vivek Khera <kh...@kciLink.com>.
>>>>> "TS" == Tim Sweetman <ti...@aldigital.co.uk> writes:

TS> you can add directories to @INC by putting

TS> PerlSetEnv PERL5LIB /home/httpd/perl


Just use the second method in the guide.  ie, use lib '/path/to/lib'
in a startup script.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/