I'm curious, how would this be
possible with mod_perl?  The below will fail as:

$r->add_config() has failed: <VirtualHost not allowed here

and when size="-1">$r->add_config face="sans-serif"> is changed to $r->server->add_config size="-1"> it will fail as:

Can't run '$s->add_config' after server startup

In /etc/hosts	local.example.com

In httpd.conf

PerlInitHandler Apache::Handlers::MyInitHandler


package Apache::Handlers::MyInitHandler;
use strict;
our $VERSION = 0;

use Apache2::RequestUtil ();
use Apache2::Const -compile => qw(DECLINED);

sub handler {
my $r = shift;
'<VirtualHost *:80>',
'ServerName local.example.com',
'DocumentRoot /var/www/example.com/htdocs',
'<Directory /var/www/example.com/htdocs>',
'Order allow,deny',
'Allow from all',
'AllowOverride None',
'Options None',


Perrin Harkins wrote:
cite="mid66887a3d0803280800h183ecerd5c2fcb921921bed@mail .gmail.com"
On Fri, Mar 28, 2008 at 8:30 AM, Valerio <valerio.bontempi@gmail.com> wrote:

 Instead I need a solution that allow adding a vhost to the database
without need of restarting apache.

This is not usually done with mod_perl because there are
lighter-weight solutions available. There's some info on vhosts with
mod_rewrite and mod_vhost_alias here:

You can find apache modules built specifically for dynamically pulling
vhosts from a database here:

You certainly could do this from mod_perl, but I wouldn't.

- Perrin