InfiniteLoop has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,
I have intriguing problem, although not uncommen. My application runs on apache 1.x + mod_perl. I have a generic httpd.conf, in which I set the PERL5LIB and the path to my html templates. Now I have mutliple versions of the applications and my manager wants to run each of these versions from a single apache instance.

I have a startup.pl script which sets various other environment variable required by the application. When I set up the virtual host, I found that the last call to startup.pl would over write other environment variables.

How do I setup mod perl instances for each virtual host ? Is this possible ?

Replies are listed 'Best First'.
Re: mod_perl and multiple virtual host
by Fletch (Bishop) on Jan 16, 2006 at 23:47 UTC

    If you can swing it a better place to put the path to your templates would be in a PerlSetVar directive and have something like:

    <VirtualHost ...:80> ## . . . PerlSetVar TEMPLATE_PATH /www/host.../templates ## . . . </VirtualHost> ## then in your handler use . . . my $template_path = $r->dir_config( 'TEMPLATE_PATH' );

    If you're stuck reading from the environment, you might have a FixupHandler which uses this method to set the environment variable you're using now before the content phase gets run (and maybe a cleanup handler to unset it just to be paranoid . . . :).

    Update: And just to clarify this doesn't address possibly having multiple versions of code for different virtual servers. To handle that you'd need to do something similar to what Apache::Registry does by pulling things into separate packages.

      Wonderful. Thanks. Will try this out. Also I found this resource mod perl book