clinton has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to configure virtual hosts dynamically in mod_perl2.
I have a startup file which sets up an 'application' based on my own framework. Part of that inflation creates a number of virtual hosts.
I have been trying the following:
------------------------- In httpd.conf: PerlConfigRequire /path/startup.pl ------------------------- In startup.pl: .... my $config = <<VHOST <VirtualHost 127.0.0.1> # Config </VirtualHost> VHOST Apache2::Server->server->add_config([split /\n/ $config]); -------------------------
When I tried with PerlRequire or PerlPostConfigRequire, adding the virtual host would give me a segfault.
With PerlConfigRequire, it runs fine, but if I do:
@vhosts = Apache2::Directive::conftree->lookup("VirtualHost")
it doesn't find any virtual hosts.
I want to keep the line in httpd.conf as simple as possible. How should I go about doing this?
I could use PerlSections, but how?
<Perl> my $config = do 'startup.pl'; #parse config into @vhosts foreach my $vhost (@vhosts) { $VirtualHost{$vhost}=>$config->{$vhost} } </Perl>
Or should I use something like:
<Perl handler="startup.pl"> </Perl>
Or:
PerlOpenLogsHandler startup.pl
Help appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Configuring virtual hosts dynamically with mod_perl
by Fletch (Bishop) on Aug 14, 2006 at 13:48 UTC | |
|
Re: Configuring virtual hosts dynamically with mod_perl
by clinton (Priest) on Aug 14, 2006 at 16:08 UTC |