You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Roman Maeder <ma...@mathconsult.ch> on 2001/06/02 14:29:32 UTC
PerlSetEnv scoping (again)
back in 1998 and 99 there was a longer discussion about scoping problems
with PerlSetEnv (inside httpd.conf and .htaccess files), which ended
with fixes applied to mod_perl-1.20, which is the version I have been
using (along with apache-1.3.6 and perl 5.00404)
Now I am setting up a brand new machine to replace my aging web server
and compiled Perl 5.6.1, apache_1.3.20, and mod_perl-1.25 (Solaris 8)
and the old problem is back, only worse. This is so severe I can't
imagine it happening in all configurations out there, but here is
what I found.
Summary:
1 a variable defined with PerlSetEnv in the main server (outside any
virtual hosts) cannot be changed inside a virtual host section (the
change is ignored)
2 a variable defined inside a virtual host section is visible to all
*other* virtual hosts and the main server
3 a variable defined in httpd.conf cannot be changed inside a .htaccess
file (the change is ignored)
I set up my Apache with a minimal httpd.conf and two IP-based
virtual hosts (besides the main server), configured like this
(plus the necessary "AllowOverride All", etc.; see attached file)
# main server
DocumentRoot "/www/test/root"
PerlSetEnv VarA Global
PerlSetEnv VarB Global
# virthost 1
<VirtualHost IP1>
DocumentRoot "/www/test/root1"
PerlSetEnv VarA VirtHost1
PerlSetEnv VarC VirtHost1
</VirtualHost>
# virthost 2
<VirtualHost IP2>
DocumentRoot "/www/test/root2"
PerlSetEnv VarA VirtHost2
</VirtualHost>
additionally, /www/test/root2 contains this .htaccess file
PerlSetEnv VarB root2
PerlSetEnv VarD root2
Using a Apache::Registry script to print the enviroment in all three
servers (main and the two virtual hosts), I get these values
Var main virthost1 virthost2
VarA Global Global* Global*
VarB Global Global Global*
VarC VirtHost1* VirtHost1 VirtHost1*
VarD - - root2
the entries with the * are wrong, I think.
Has anyone seen something like this before?
Regards,
Roman Maeder
Re: PerlSetEnv scoping (again)
Posted by Doug MacEachern <do...@covalent.net>.
i will add this to the ToDo to look at before 1.26. in the meantime, if
you don't need to access these variables before the fixup stage and don't
need %ENV to be inherited by a forked program, try changing PerlSetEnv to
SetEnv.
On Sat, 2 Jun 2001, Roman Maeder wrote:
> back in 1998 and 99 there was a longer discussion about scoping problems
> with PerlSetEnv (inside httpd.conf and .htaccess files), which ended
> with fixes applied to mod_perl-1.20, which is the version I have been
> using (along with apache-1.3.6 and perl 5.00404)
>
> Now I am setting up a brand new machine to replace my aging web server
> and compiled Perl 5.6.1, apache_1.3.20, and mod_perl-1.25 (Solaris 8)
> and the old problem is back, only worse. This is so severe I can't
> imagine it happening in all configurations out there, but here is
> what I found.
>
> Summary:
>
> 1 a variable defined with PerlSetEnv in the main server (outside any
> virtual hosts) cannot be changed inside a virtual host section (the
> change is ignored)
>
> 2 a variable defined inside a virtual host section is visible to all
> *other* virtual hosts and the main server
>
> 3 a variable defined in httpd.conf cannot be changed inside a .htaccess
> file (the change is ignored)
>
>
> I set up my Apache with a minimal httpd.conf and two IP-based
> virtual hosts (besides the main server), configured like this
> (plus the necessary "AllowOverride All", etc.; see attached file)
>
> # main server
>
> DocumentRoot "/www/test/root"
>
> PerlSetEnv VarA Global
> PerlSetEnv VarB Global
>
>
> # virthost 1
>
> <VirtualHost IP1>
> DocumentRoot "/www/test/root1"
>
> PerlSetEnv VarA VirtHost1
> PerlSetEnv VarC VirtHost1
>
> </VirtualHost>
>
>
> # virthost 2
>
> <VirtualHost IP2>
> DocumentRoot "/www/test/root2"
>
> PerlSetEnv VarA VirtHost2
>
> </VirtualHost>
>
>
> additionally, /www/test/root2 contains this .htaccess file
>
> PerlSetEnv VarB root2
> PerlSetEnv VarD root2
>
>
> Using a Apache::Registry script to print the enviroment in all three
> servers (main and the two virtual hosts), I get these values
>
> Var main virthost1 virthost2
>
> VarA Global Global* Global*
> VarB Global Global Global*
> VarC VirtHost1* VirtHost1 VirtHost1*
> VarD - - root2
>
> the entries with the * are wrong, I think.
>
> Has anyone seen something like this before?
>
>
> Regards,
>
> Roman Maeder
>
>