I am building a mod_perl website, and I need to set an environment variable that will be used in the Perl code.
Until now I was using the PerlSetEnv
directive to set this variable:
PerlSetEnv MYVAR myvalue
<LocationMatch /perlpath/>
SetHandler modperl
PerlResponseHandler myhandler
Header set Cache-control "no-cache"
</LocationMatch>
This works fine, but I'd like to preload my mod_perl handler, because the first call is very slow. So I changed my Apache virtualhost file to:
PerlSetEnv MYVAR myvalue
PerlModule myhandler <- add this line
<LocationMatch /perlpath/>
SetHandler modperl
PerlResponseHandler myhandler
Header set Cache-control "no-cache"
</LocationMatch>
But if I do this, my custom environment variable MYVAR
is not set when preloading myhandler
, and my code fails.
So is it possible to set an environment variable that will be exported by the PerlModule
directive?