I'd like to dynamically configure Apache using an external Perl script. i.e., in httpd.conf:
PerlRequire myhttpdconf.pl Since I'm using a database to define how I'd like to configure multiple virtual hosts on my server, my Perl script iterates through records to produce the necessary Apache configuration: myhttpdconf.pl: package Apache::ReadConfig; use Apache::ServerUtil (); ...database query/fetch... ...iterate through records... With all the books and web references on hand, I've already tried numerous approaches to get things working, but have been unsuccessful. The only thing that has worked has been to generate my Apache configuration syntax as text and then copy/paste it into the httpd.conf file (obviously not as dynamic as I'd like): Here's a summary of what I've tried (unsuccessfully) in the myhttpdconf.pl file: 1) appending Apache syntax to $PerlConfig, i.e., "$PerlConfig .= "<VirtualHost 1.2.3.4:80>\n", etc. 2) same as #1, but pushing lines onto @PerlConfig array 3) Apache->server->add_config($line), for each $line in my $myconfig (similar as approach #1, but using add_config rather than $PerlConfig, and prepending the entire block with "<Perl>", and appending "</Perl>".) I have also tried using the Perl Syntax within the external script (i.e. "<Perl>\n$VirtualHost{ ... }\n</Perl>") but found it too complicated for my needs, particularly since most of my virtual hosts have the same IP/port. I'm hoping that someone can shed some light on this topic. I think the ideal way for me to do this is with the $PerlConfig var, but it seems that perhaps this area has changed considerably since mp1, and is perhaps the API is still in flux. FYI, Here's an example of a typical VirtualHost configuration for my server (there are many of these, mostly sharing the same IP:port): <VirtualHost 1.2.3.4:443> ServerName www.hostA.com PerlSetVar myvar_A value1 PerlSetEnv myenvvar_A value1 SetHandler perl-script PerlInitHandler myhandler1 PerlTransHandler myhandler2 SSLEngine on SSLCertificateFile conf/ssl/host_A.crt SSLCertificateKeyFile conf/ssl/host_A.key </VirtualHost> My system is: Apache/2.0.48 (Unix) mod_perl/1.99_11 Perl/v5.8.2 mod_ssl/2.0.48 OpenSSL/0.9.7c thanks Eric -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html