Re: apache2 <perl> sections: "*:80 has no VirtualHosts" error
On Monday 05 April 2004 05:19 pm, Will Trillich wrote:
> the debian (sarge) incarnation of apache 2 is, according to the
> readmes, reswizzled a bit from the upstream defaults... so i'll
> ask this here at debian-user (maybe it's debian specific?)
>
> okay. we're trying to use <perl> sections in apache2.conf to
> configure virtual hosts -- here's Data::Dumper showing the
> %VirtualHost hash:
>
> %VirtualHost = {
> '*:80' => [
> {
> 'PerlSetVar' => [
> 'SiteName',
> 'one'
> ],
> 'Directory' => {
> '/var/www/one' => {
> 'Options' => [
> '+Indexes',
> ],
> 'FilesMatch' => {
> '^[A-Z]|\\.mc$' => {
> 'SetHandler' => 'perl-script',
> 'PerlResponseHandler' => 'Apache::NOT_FOUND'
> },
> '\\.(html|css)$' => {
> 'SetHandler' => 'defaulthandler'
> }
> }
> }
> },
> 'ServerName' => 'one',
> 'DocumentRoot' => '/var/www/one',
> 'ServerAlias' => [
> 'five',
> 'seven'
> ]
> },
> {
> 'PerlSetVar' => [
> 'SiteName',
> 'three'
> ],
> 'Directory' => {
> '/var/www/three' => {
> 'Options' => [
> '+Indexes',
> ],
> 'FilesMatch' => {
> '^[A-Z]' => {
> 'SetHandler' => 'perl-script',
> 'PerlHandler' => 'Apache::NOT_FOUND'
> },
> '\\.(html|css)$' => {
> 'SetHandler' => 'defaulthandler'
> }
> }
> }
> },
> 'ServerName' => 'three',
> 'DocumentRoot' => '/var/www/three'
> }
> ]
> };
>
> site "one" has aliases "five" and "seven"; site "three" is on
> its own. (we're testing, see -- /etc/hosts has all these names
> as aliases for "localhost".)
>
> when trying to use this config, apache2 belches
>
> NameVirtualHost *:80 has no VirtualHosts
>
> we'd love to know why. pointers are very welcome!
=====================================================
Hi Will!
I have no perl skills but this error is caused when apache2 decides that there
is no additional hosts to serve than the default. In Debian/Sarge apache2 is
configured with multiple small configs for each site rather than listing them
in apache2.conf. (just covering the basics) the default site needs to be
replaced with the file /etc/apache2/sites-available/yourmainhost which is
symlinked to /etc/apache2/sites-enabled/@yourmainhost the first line of this
file works best for listening on all ports if it is set to
"NameVirtualHost*:80" DO NOT INCLUDE THIS LINE IN ANY OTHER SITE CONFIG THAT
YOU MAKE! Then you can create as many other sites as needed by creating the
files /etc/apache2/sites-available/yoursecondhost which is symlinked
to /etc/apache2/sites-enabled/@yoursecondhost and so on. I also think (just
an idea) that you might want to only use an "Include" statement for you perl
script at the end of apache2.conf and put that script elsewhere so that if
you need to modify the perl script you don't have to completely start over
but only modify it and restart apache2:-) All this is based on guessing at
what type of VirtualHost you are running, but I use name based as it is much
easier to configure that a system using ip addressing.
BTW none of this is in the new manual or the Debian docs that I coul find.
Best wishes.
--
John Foster
Reply to: