From: Philip Reynolds (phil at domain redbrick.dcu.ie)
Date: Fri 22 Jun 2001 - 17:37:02 IST
adam's [adam at domain iewebs.com] 49 lines of wisdom included:
> Having written a nice set of RewriteRules for mass virtual hosting I decided
> in true *nix-fan fashion to throw it all out and use perl sections instead.
> But I can't get it working, and because I can't figure out a way of
> debugging, I don't know why. Here's the perl section:
For debugging:
$Apache::Server::StrictPerlSections = 1;
That makes it use StrictPerlSections which aids in deubgging,
however debugging is done on the compile of mod_perl, which you
presumably didn't do because it's a RedHat box.
If you compiled it with PERL_TRACE=1 then you get some useful
debugging info.
> So you can see, I'm telling Apache to Listen on the relevant IP address with
> a NameVirtualHost directive, and then I'm creating the VirtualHosts on the
> fly from a directory listing of /home/sites, which is where, predictably
> enough, the sites are. However Apache doesn't appear to be loading the perl
> sections config fully. It *is* loading the NameVirtualHost directive though.
> If I comment out everything from opendir() to closedir() httpd -t throws an
> notice:
>
> [Fri Jun 22 16:18:16 2001] [warn] NameVirtualHost 192.168.0.2:80 has no
> VirtualHosts
> Syntax OK
>
> Which implies that there's something wrong with the VirtualHosts hash
> itself. But what?
<PERL>
#!/usr/bin/perl
my $ip = "136.206.15.101";
my $dir = "/tmp/vhosts";
my $site;
$NameVirtualHost = $ip;
opendir(DIR, $dir);
foreach $site (readdir(DIR)) {
if (($site ne ".") && ($site ne "..")) {
%{$VirtualHost{$ip}} = (
"ServerName" => "$site",
"ServerAlias" => "www.$site",
"DocumentRoot" =>
"/tmp/vhosts/$site/web"
);
print "ServerName => " .
$VirtualHost{$ip}{'ServerName'} . "\n";
}
}
</PERL>
[Fri Jun 22 19:36:51 2001][F][D][Job]
[~][phil at domain acloseshave] ls -R /tmp/vhosts
/tmp/vhosts:
pip.redbrick.dcu.ie
/tmp/vhosts/pip.redbrick.dcu.ie:
web
/tmp/vhosts/pip.redbrick.dcu.ie/web:
index.html
[Fri Jun 22 19:37:18 2001][F][D][Job]
[~][phil at domain acloseshave]
It works perfectly, have you checked the usual? mod_vhosts loaded?
Does the vhost work with a normal Apache VirtualHost directive, with
the exact same options you have speified?
Phil.
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:10:50 GMT