The Problem
You restart Apache and get a nice NameVirtualHost *:80 has no VirtualHosts warning message, on the screen, or in the error log. Why, and how do you get rid of it?The cause of this is simple, although the warning seems counterintuitive, since most likely you're seeing it after deliberately creating one or more virtual hosts in your Apache configuration.
If you're using Include configuration files, look carefully in the main configuration file, and in the Included files. You will see multiple occurrences of the NameVirtualHost directive, like this:
In one configuration file (for example, httpd.conf):
NameVirtualHost *:80
In another configuration file (for example, extra/httpd-vhosts.conf):
NameVirtualHost *:80
The solution is to comment out the second one that is processed, and you will eliminate the warning.
How this manifested
For me, this occurred when I manually added a vhost to my development workstation, which is running Zend Server 6. I did not want to use its Application Deployment capability for local development, since I preferred in this case to just edit code, flip to my browser, and refresh.I reserve Zend Server Application Deployment for deploying to a remote server, although I certainly test deployments locally first. There is a simple way to deploy once, and have edited code auto-saved to the server, so it is NOT at all necessary to avoid Application Deployment in local development, but that is a topic for another post.
Anyway, /usr/local/zend/apache2/conf/httpd.conf originally contained this commented directive:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
and /usr/local/zend/apache2/conf/extra/httpd-vhosts.conf originally contained the two dummy-host.example.com sample vhosts. I commented these out and added my vhost:
# Virtual hosts
<VirtualHost *:10088>
ServerName dev.florists.local
ServerAdmin clark.e@zend.com
DirectoryIndex index.php index.html
SetEnv APPLICATION_ENV development
DocumentRoot "/Users/eai/vhosts/florists/public"
LogLevel warn
php_value session.save_path "/path/to/my/development/session/directory"
php_value upload_tmp_dir "/path/to/my/development/uploads/directory"
<Directory /Users/eai/vhosts/florists/public>
Options Indexes MultiViews FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I then uncommented the #Include conf/extra/httpd-vhosts.conf line in httpd-vhosts.conf, and restarted apache with
$ sudo /usr/local/zend/bin/zendctl.sh restart-apache
and saw the warning:
Mon Sep 02 03:33:20 2013] [warn] NameVirtualHost *:10088 has no VirtualHosts
Looking at the two configuration files, this appeared in http.conf:
Include /usr/local/zend/apache2/conf.d/
#ZEND-{2F-blah-blah...}
NameVirtualHost *:10088
#ZEND-{13-blah-blah...}
Include "/usr/local/zend/etc/sites.d/zend-default-vhost-10088.conf"
#ZEND-{13-blah-blah...}
#ZEND-{2F-blah-blah...}
#ZEND-{AF-blah-blah...}
Include "/usr/local/zend/etc/sites.d/globals-*.conf"
Include "/usr/local/zend/etc/sites.d/vhost_*.conf"
#ZEND-{AF-blah-blah...}
And this was in http-vhosts.conf (this is what I hadn't paid any attention to):
#
# Use name-based virtual hosting.
#
NameVirtualHost *:10088
So, the directive was being processed twice. This is merely a warning, since Apache will actually ignore the second directive and use only the first defined NameVirtualHost directive. If you're a Debian user and seeing this warning, take a peek at the ports.conf file.
How to Fix
Just comment out the second occurrence to be processed. In my case, this is the one in the main httpd.conf file, since the Include of the httpd-vhosts file comes before that line:#ZEND-{2F-blah-blah...}
# Manually including conf/extra/httpd-vhosts.conf obviates this line - NameVirtualHost *:10088
#ZEND-{13-blah-blah...}
Restart again, and the warning is gone.