You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Will Fould <wi...@gmail.com> on 2006/06/02 19:34:41 UTC

Using PerlSetVar in virtual environments

Hello -- I'm have a 'contamination' issue using PerlSetVar in a virtual
environment.
I'm wondering if my trouble is from my use of 'require' or from using
non-unique PerlSetVar variable names (although, under separate virtual
containers). While we can continue to run separate Apache instances for each

site, I want to bundle multiple smaller sites under at least one of
the instances.

Can someone spot the weakness here?

In testing, I've got Example1 and Example2 virtual directives:

       <VirtualHost NNN.NN.NN.NNN:80>
               ServerName example1.com
       ...
                   <Location /var/example1/>
                   PerlSetVar foo /var/example1/site.conf
                   </Location>
       </VirtualHost>

       <VirtualHost NNN.NN.NN.NNN:80>
               ServerName example2.com
       ...
                   <Location /var/example2/>
                   PerlSetVar foo /var/example2/site.conf
                   </Location>
       </VirtualHost>

In the scripts under each site, I use:

       my $r=Apache2::RequestUtil->request;
       $site_conf=$r->dir_config('foo ');
       require "$site_conf";


Eventually, Example2 site uses details specified in example1/site.conf

Must 'foo' be unique under each virtual environment? (i.e. foo1, foo2)


Thank you for helping!
Will

Re: Using PerlSetVar in virtual environments

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2006-06-02 at 10:34 -0700, Will Fould wrote:
> I'm wondering if my trouble is from my use of 'require'

Most likely.  You didn't show us what's in the required file, but I'm
guessing it just sets a bunch of variables.  If you really want this to
load that file on every request, change require to "do" instead.

A better way is to load all the data into a hash and then use something
from the PerlSetVar as an index to tell which data in the hash to use
for this request.  That avoids reloading the file over and over.

- Perrin