Short Tip: Check configured virtual hosts in Apache

Whenever you have to debug virtual host setups in Apache, checking the actual running virtual host configuration is a good first step. This can be done with the -S option used on the Apache binary: It lists all running virtual hosts and performs a syntax check.

On Fedora, RHEL, CentOS the Apache binary can be found on /usr/sbin/httpd:

# /usr/sbin/httpd -S
VirtualHost configuration:                                                (/etc/httpd/conf.d/me.conf:5) (/etc/httpd/conf.d/others.conf:1) (/etc/httpd/conf.d/others.conf:38)
Syntax OK

On Debian systems the call is almost the same, you just have to source the environment variables upfront, and the binary has a different name for historical reasons:

# source /etc/apache2/envvars
# /usr/sbin/apache2 -S
VirtualHost configuration:                                                (/etc/apache2/sites-enabled/me.conf:5) (/etc/apache2/sites-enabled/others.conf:1) (/etc/apache2/sites-enabled/others.conf:38)
Syntax OK

you might run into an error about user names, in such cases it is helpful to call upfront.

2 thoughts on “Short Tip: Check configured virtual hosts in Apache

Comments are closed.