2

my setup is as follows: I have one Apache2 webserver running different vhosts, one vhost is for the production website, the other vhost is for a staging / preview system. Both vhosts have different DocumentRoots and also different (Perl) CGI folders. The used modules for each of these vhosts should be in different directories, so I did the following:

<VirtualHost...>
ServerName production
SetEnv PERL5LIB /home/production/modules
</VirtualHost>

<VirtualHost...>
ServerName staging
SetEnv PERL5LIB /home/staging/modules
</VirtualHost>

However, I just noticed that in my Perl CGI scripts, both paths get filled into my @INC, so I can not separate the staging modules from the production modules, e.g. the SetEnv directive is not limited to a single virtual host, but seems to work globally.

How can I solve this?

Thanks! Jonas

j0nes
  • 945
  • 10
  • 25

2 Answers2

2
  <VirtualHost ...>
      ServerName dev1
      PerlOptions +Parent
      PerlSwitches -I/home/dev1/lib/perl
  </VirtualHost>

  <VirtualHost ...>
      ServerName dev2
      PerlOptions +Parent
      PerlSwitches -I/home/dev2/lib/perl
  </VirtualHost>
dengel
  • 121
  • 3
0

I found something called SetEnvIf which can be used to set environment variables based on the request headers. eg.

SetEnvIf Request_URI "\request-for-staging\" PERL5LIB=/home/staging/modules

But that maybe too heavy...so you could try mod_rewrite's [E=...] option.

Hope that helps :)

Knight Samar
  • 109
  • 1
  • 10