How to add script specific lib path to mod_perl?

I am trying to port CGI scripts to mod_perlusing ModPerl::Registry.

Scripts use modules that are in the same directory as the script, but since the mod_perlcurrent directory is in a different location, this does not work.

I tried using FindBinto add to @INC, but here's what FindBinit looks like:

$FindBin::Bin: /usr/sbin
$FindBin::Script: httpd

It's useless.

So, is there a way for the script to find out where it is and add this directory to @INC? Ideally, all other scripts using the same Apache server could not add this directory to their own @INC.

+3
source share
4
use File::Basename;
use lib dirname( __FILE__ );
+5

httpd.conf :

PerlRequire /location/of/this/script/startup.pl

startup.pl , :

use lib qw(/location/of/module1 /location/of/module1); 1;

Presto!

+2

Location Directory script ? , PerlSetEnv

Alias /apps/thisone/ /srv/http/site/apps/thisone/
<Location /apps/thisone/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    PerlSetEnv MYLIB /srv/http/site/apps/thisone/lib
    Options +ExecCGI
    Order allow,deny
    Allow from all 
</Location>

:

Alias /apps/ /srv/http/site/apps/
<Location /apps/thisone/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    PerlSetEnv THISONE_LIB /srv/http/site/apps/thisone/lib
    PerlSetEnv THATONE_LIB /srv/http/site/apps/thisone/lib
    Options +ExecCGI
    Order allow,deny
    Allow from all 
</Location>
+1

lib::abs. , , mod_perl.

+1

Source: https://habr.com/ru/post/1713239/


All Articles