How to debug an apache virtual host configuration? How to debug an apache virtual host configuration? apache apache

How to debug an apache virtual host configuration?


Syntax check

To check configuration files for syntax errors:

# Red Hat-based (Fedora, CentOS) and OSXhttpd -t# Debian-based (Ubuntu)apache2ctl -t# MacOSapachectl -t

List virtual hosts

To list all virtual hosts, and their locations:

# Red Hat-based (Fedora, CentOS) and OSXhttpd -S# Debian-based (Ubuntu)apache2ctl -S# MacOSapachectl -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).