How to debug an apache virtual host configuration?
First check out config files for syntax errors with apachectl configtest
and then look into apache error logs.
Syntax check
To check configuration files for syntax errors:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -t
# Debian-based (Ubuntu)
apache2ctl -t
# MacOS
apachectl -t
List virtual hosts
To list all virtual hosts, and their locations:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -S
# Debian-based (Ubuntu)
apache2ctl -S
# MacOS
apachectl -S
Here's a command I think could be of some help :
apachectl -t -D DUMP_VHOSTS
You'll get a list of all the vhosts, you'll know which one is the default one and you'll make sure that your syntax is correct (same as apachectl configtest suggested by yojimbo87).
You'll also know where each vhost is declared. It can be handy if your config files are a mess. ;)
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options).