Correct way listing NameVirtualHosts in httpd.conf?

Jeff75

Well-Known Member
Apr 11, 2003
555
0
166
Can someone tell me what the correct way to have NameVirtualHosts in the httpd.conf is? Each account on my server has it's own IP address. Should there be a NameVirtualHost at the very top of the VirtualHost section or right above the first VirtualHost for the domain. cPanel currently has them all over the place and it's really nasty. I'm trying to figure out how to fix the NameVirtualHost [IP] has no VirtualHost errors (about 300) and it's a PITA.
 

PWSowner

Well-Known Member
Nov 10, 2001
2,948
4
343
ON, Canada
There is no "correct" way as long as they are before the first VirtualHost entry.

When I clean up my conf file, I put all my NameVirtualHost entries together just before the VirtualHost entries.

When doing any changes to that file, it's good to save a backup of the original, just in case something is done wrong in the modifications. Gives a quick way to get apache back up.
 

Jeff75

Well-Known Member
Apr 11, 2003
555
0
166
Thanks for the info. If I set up my NameVirtualHosts the way like you described, would those warnings still come up when doing configtest?
 

PWSowner

Well-Known Member
Nov 10, 2001
2,948
4
343
ON, Canada
Nope.

The NameVirtualHost [IP] has no VirtualHost errors means there is a NameVirtualHost entry but the IP isn't used for any accounts. List all the NameVirtualHost entries above the VirtualHost entries, then with any IP's that give that error, check to make sure there are no sites using them and remove that NameVirtualHost entry. You can just leave them there if you want. They do no harm. What happens is, if an account with a ded IP is terminated, the NameVirtualHost entry is usually left behind.