You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Erik Scholtz <e....@argonsoft.de> on 2005/07/12 12:23:31 UTC
vhosts and mod_perl
Hello,
I have two vhosts, each running with a different project. Both projects
are using a "config.pm", located directly in the cgi-bin directory.
Now it happens, that the project1 uses the config.pm of project2 and
vice versa.
I have no idea, why this happens. Anyone of you a hint for me?
Config of the two vhosts:
-------------------------
<VirtualHost project1.mydomain.com>
ServerName project1.mydomain.com
ServerAdmin myemail@mydomain.com
DocumentRoot /path/to/mydomain.com/project1/www
<Location /cgi-bin/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlInitHandler Apache::Reload
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
</VirtualHost>
<VirtualHost project2.mydomain.com>
ServerName project2.mydomain.com
ServerAdmin myemail@mydomain.com
DocumentRoot /path/to/mydomain.com/project2/www
<Location /cgi-bin/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlInitHandler Apache::Reload
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
</VirtualHost>
Head of perlscript on project1:
-------------------------------
#!/usr/bin/perl
###
use strict;
use lib '/path/to/mydomain.com/project1/www/cgi-bin/';
use config;
my $config = &config;
...
Head of perlscript on project2:
-------------------------------
#!/usr/bin/perl
###
use strict;
use lib '/path/to/mydomain.com/project2/www/cgi-bin/';
use config;
my $config = &config;
...
Server version:
---------------
Server Version: Apache/2.0.54 (Unix) mod_perl/1.999.22 Perl/v5.8.6
Server Built: May 4 2005 20:47:57
Best regards,
Erik
Re: vhosts and mod_perl
Posted by Maxim Nechaev <ne...@technodesign.ru>.
You can solve this by adding:
<VirtualHost project1.mydomain.com>
....
PerlOptions +Parent
....
</VirtualHost>
<VirtualHost project2.mydomain.com>
....
PerlOptions +Parent
....
</VirtualHost>
http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_
--
Maxim Nechaev
Re: vhosts and mod_perl
Posted by Stas Bekman <st...@stason.org>.
Malcolm J Harwood wrote:
> On Tuesday 12 July 2005 06:23 am, Erik Scholtz wrote:
>
>
>>I have two vhosts, each running with a different project. Both projects
>>are using a "config.pm", located directly in the cgi-bin directory.
>>
>>Now it happens, that the project1 uses the config.pm of project2 and
>>vice versa.
>>
>>I have no idea, why this happens. Anyone of you a hint for me?
>
>
> Sure. The problem is that modperl is persistant by design.
> So what you get is:
> server child 1 responds to project1 request, loads config.pm from project1.
> server child 2 responds to project2 request, loads config.pm from project2.
> server child 1 responds to project2 request, already has config.pm from
> project1 loaded, uses that. ("use config" isn't
> server child 2 responds to project1 request, already has config.pm from
> project2 loaded, uses that.
>
> You need to namespace the configs, (eg. Project1::Config) and make sure that
> what they export doesn't overlap.
Also documented in deal at:
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs
:)
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: vhosts and mod_perl
Posted by Malcolm J Harwood <mj...@liminalflux.net>.
On Tuesday 12 July 2005 06:23 am, Erik Scholtz wrote:
> I have two vhosts, each running with a different project. Both projects
> are using a "config.pm", located directly in the cgi-bin directory.
>
> Now it happens, that the project1 uses the config.pm of project2 and
> vice versa.
>
> I have no idea, why this happens. Anyone of you a hint for me?
Sure. The problem is that modperl is persistant by design.
So what you get is:
server child 1 responds to project1 request, loads config.pm from project1.
server child 2 responds to project2 request, loads config.pm from project2.
server child 1 responds to project2 request, already has config.pm from
project1 loaded, uses that. ("use config" isn't
server child 2 responds to project1 request, already has config.pm from
project2 loaded, uses that.
You need to namespace the configs, (eg. Project1::Config) and make sure that
what they export doesn't overlap.
--
The universe is run by the complex interweaving of three
elements: energy, matter, and enlightened self-interest.
- G'kar, Babylon 5