Yo,
Has anyone successfully built a fully perl conf file with multiple virtual
hosts on the same IP? I'm giving it my best, but just can't quite get it to
work. I'm stuck on aliases. The Eagle book and the mod_perl guide have
both been of great help getting this far, but I can't find an example of
setting anything where "Directive is Repeated Multiple Times" (which may be
an indication that it just don't work). I just started on this project, and
this is the first major roadblock. Here are the relevant portions (I hope)
of the config for reference. Thank you in advance for any and all
help/clues. This is getting deeper than I've previously gotten, so I'm
learning as I go. An RTFM is welcome, just tell me which M and where. :)
<Perl>
#!/usr/local/bin/perl
# Trimmed for brevity here... the real file is MUCH larger
$Apache::Server::StrictPerlSections = 1;
$Apache::Server::SaveConfig = 1;
$ServerName = `hostname`;
$ServerType = 'standalone';
$ServerRoot = '/www';
my $conf_root = $ServerRoot . '/conf';
my $logs_root = $ServerRoot . '/logs';
my $vhosts_root = $ServerRoot . '/vhosts';
# olorin eq prod, erasmus eq dev
if ($ServerName =~ /olorin/) {
$NameVirtualHost = '192.168.0.3';
}
elsif ($ServerName =~ /erasmus/) {
$NameVirtualHost = '192.168.0.2';
}
my $NameVirtualHostIP = $NameVirtualHost . ':80';
$KeepAlive = 'Off';
$ExtendedStatus = 'On';
$UseCanonicalName = 'Off';
$HostnameLookups = 'Off';
$LogLevel = 'warn';
$VirtualHost{$NameVirtualHostIP} = [
# WWW.ACQUISITIONS.ORG
{
ServerName => 'www.acquisitions.org',
ServerAlias => 'acquisitions.org',
DocumentRoot => "$vhosts_root/www.acquisitions.org/htdocs",
ScriptAlias => [
'/cgi-bin/' => "$vhosts_root/www.acquisitions.org/cgi-bin/"
],
CustomLog => "$logs_root/www.acquisitions.org_access_log combined",
ErrorLog => "$logs_root/www.acquisitions.org_error_log",
},
# MEMBERS.RECKONING.ORG
{
ServerName => 'members.reckoning.org',
Alias => {
[ '/images' => "$vhosts_root/members.reckoning.org/images"
],
[ '/css' => "$vhosts_root/members.reckoning.org/css" ],
},
ErrorLog => "$logs_root/members.reckoning.org_error_log",
TransferLog => "$logs_root/members.reckoning.org_access_log",
PerlAuthenHandler => 'Apache::AuthDBI::authen',
PerlSetVar => {
Auth_DBI_data_source => 'dbi:Pg:dbname=reckdb',
Auth_DBI_username => 'dvicci',
Auth_DBI_pwd_table => 'user_profile',
Auth_DBI_uid_field => 'user_username',
Auth_DBI_pwd_field => 'user_password',
Auth_DBI_pwd_whereclause => '"user_usertype>0"',
Auth_DBI_encrypted => 'off',
},
Location => {
'/' => {
SetHandler => 'perl-script',
PerlInitHandler => 'Apache::StatINC',
PerlHandler => 'Reckoning::IndexHandler::members',
AuthName => 'theReckoning',
AuthType => 'Basic',
Limit => {
'GET POST' => {
require => 'valid-user',
},
},
},
'/images' => {
SetHandler => 'default-handler',
},
'/css' => {
SetHandler => 'default-handler',
},
'/Error' => {
SetHandler => 'perl-script',
PerlHandler => 'Reckoning::Error',
},
'/LoginError' => {
SetHandler => 'perl-script',
PerlHandler => 'Reckoning::LoginError',
},
},
ErrorDocument => {
'401' => '/LoginError',
}
},
# WWW.RECKONING.ORG
{
ServerName => 'www.reckoning.org',
ServerAlias => 'reckoning.org',
Alias => {
[ '/images' => "$vhosts_root/members.reckoning.org/images"
],
[ '/css' => "$vhosts_root/members.reckoning.org/css" ],
},
ErrorLog => "$logs_root/www.reckoning.org_error_log",
TransferLog => "$logs_root/www.reckoning.org_access_log",
Location => {
'/' => {
SetHandler => 'perl-script',
PerlInitHandler => 'Apache::StatINC',
PerlHandler => 'Reckoning::IndexHandler::www',
},
'/images' => {
SetHandler => 'default-handler',
},
'/css' => {
SetHandler => 'default-handler',
},
'/Error' => {
SetHandler => 'perl-script',
PerlHandler => 'Reckoning::Error',
},
'/LoginError' => {
SetHandler => 'perl-script',
PerlHandler => 'Reckoning::LoginError',
}
},
ErrorDocument => {
'401' => '/LoginError',
}
}
];
__END__
</Perl>