Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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 :)

share|improve this answer
  <VirtualHost ...>
      ServerName dev1
      PerlOptions +Parent
      PerlSwitches -I/home/dev1/lib/perl
  </VirtualHost>

  <VirtualHost ...>
      ServerName dev2
      PerlOptions +Parent
      PerlSwitches -I/home/dev2/lib/perl
  </VirtualHost>
share|improve this answer
    
Good idea, but I think this only works if you're running mod_perl. I'm not, and when I tried this I got a syntax error. –  Andrew Schulman Dec 11 '13 at 7:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.