Apache – Name Virtual Host errors

For some time now apache has been bugging me that there is a configuration issue with my virtual hosts, so I decided to find out what the issue was and try to resolve it. As it happens the fix was easy but not well documented.
Issue:
[warn] NameVirtualHost *:80 has no VirtualHosts
Resolution:
You can resolve this by ensuring that you virtual hosts are configured correctly. To do this you should have a NameVirtualHost for each of your ports and then be using ServerName within each virtualhost. By configuring apache this way you allow it to correctly interpret requests for different virtual hosts on the same IP Address.
Example:
In my apache2.conf file I have the following declaration
NameVirtualHost *:80
And then each of the virtual hosts is configured:
<VirtualHost *:80>
RailsEnv beta
ServerName my-app.redjamjar.net
DocumentRoot /home/rails/beta/my-app/current/public
<Directory “/home/rails/beta/my-app/current/public”>
allow from all
AllowOverride All
</Directory>
</VirtualHost>

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.