Apache 2 startup warning: NameVirtualHost *:80 has no VirtualHosts
When my Ubuntu Apache server (Apache 2) starts up I get a warning message that reads:
[warn] NameVirtualHost *:80 has no VirtualHosts
However, the web server is working fine. What might I have wrong in my site's configuration to make it give me this warning?
The configuration file in question (located in /etc/apache2/sites-available
) reads like (details removed for brevity)
<VirtualHost *>
<Location /mysite>
# Configuration details here...
</Location>
# Use the following for authorization.
<LocationMatch "/mysite/login">
AuthType Basic
AuthName "My Site"
AuthUserFile /etc/sitepasswords/passwd
Require valid-user
</LocationMatch>
</VirtualHost>
Could the fact that I'm using <Location>
be a part of the problem?
Change
<VirtualHost *>
to read
<VirtualHost *:80>
Or its (NameVirtualHost *:80) added twice in your apache2 Confing file. ( By Default its added in ports.conf file )
This should clear the error.
Aside: you shouldn't ignore this error. Apache's config, especially when globbing virtual hosts (eg Include /etc/httpd/vhosts.d/*) is not stable. That means you don't control the order of loading the hosts explicitly so the default vhost for an IP becomes the one that is loaded first, which can lead to unintended consequences.
One example of this is the default vhost for an IP will also be available on that IP, rather than its name. This can cause information to leak onto google referring to your sites IP rather than name, which can be confusing for customers.
The NameVirtualHost error above can be a hint that apache has loaded things in a non optimal way, so you shouldn't ignore it.
That could be because you have the NameVirtualHost directive in more than one place.
I don't know about other distributions, but in Ubuntu/Debian, Apache's configuration is split in several files, so you'd have to check where the duplication is (httpd.conf, apache2.conf, ports.conf, conf.d/*).
Oh, and I just found this great resource with more information: Common Apache Misconfigurations.
On a Debian/Lenny box: In /etc/apache2/ports.conf there is an additional NameVirtualHost statement - that could be the cause for this issue (there is also the same statement in /etc/apache2/sites-available/default). I commented that statement and the error disappered.
You have a NameVirtualHost without a matching VirtualHost entry.
This is typically not fatal, just an informative error.
It's because your NameVirtualHost line has a port number on it (:80
), but your VirtualHost sections don't.