> Home > News Index
Have you seen this error?
[Wed Jul 16 10:18:17 2008] [warn] NameVirtualHost *:80 has no VirtualHosts
This is a particularly annoying message because there are many questions about it on many forums and no definitive answers.
Quoting from apache2 <perl> sections: "*:80 has no VirtualHosts" error ...
In short, the following is an example that will produce the error message quoted above : NameVirtualHosts *:80 <VirtualHost foo:80> </VirtualHost> In other words, if you have 'NameVirtualHosts BLAH' and you do not have a '<VirtualHost BLAH>' directive, you get that error.
But that's not the end of the story. The following configuration also causes that error message (on "apache2 -f test.conf -S") ...
Listen 80 NameVirtualHost *:80 <VirtualHost *:80> ServerName name1.tull.net DocumentRoot /var/www/ </VirtualHost> <VirtualHost *:80> ServerName name2.tull.net DocumentRoot /var/www/ </VirtualHost> <VirtualHost *:80> ServerName name4.tull.net DocumentRoot /var/www/ </VirtualHost> <VirtualHost *> ServerName name4.tull.net DocumentRoot var/www/ </VirtualHost>
The errors are:
[Wed Jul 16 10:24:47 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence [Wed Jul 16 10:24:47 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence [Wed Jul 16 10:24:47 2008] [warn] NameVirtualHost *:80 has no VirtualHosts VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 name1.tull.net (/etc/apache2/strip.conf:4) *:80 name2.tull.net (/etc/apache2/strip.conf:10) *:80 name4.tull.net (/etc/apache2/strip.conf:16) *:* name4.tull.net (/etc/apache2/strip.conf:21)
In this configuration there are corresponding "VirtualHost *:80" definitions. What's confusing apache2 is the last definition which is "VirtualHost *", and it's reporting a warning with the wrong directive (NameVirtualHost).
Furthermore, the "VirtualHost overlap on port 80" warnings are being generated for correct directives, and no warning about the incorrect directive.
So the fix, at least for this scenario, is to ensure that all "VirtualHost" directives use the same value as specified in "NameVirtualHost".
Update 2008-07-18 ... also you don't want to have two "NameVirtualHost *:80" directives in the configuration. Multiple directives with the same arguments are not treated as one!