Short Tip: Check configured virtual hosts in Apache

920839987_135ba34fff
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:                                                        
1.2.3.4:80      me.example.net (/etc/httpd/conf.d/me.conf:5)
2.3.4.5:80      others.example.net (/etc/httpd/conf.d/others.conf:1)
2.3.4.5:443     others.example.net (/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:                                                        
1.2.3.4:80      me.example.net (/etc/apache2/sites-enabled/me.conf:5)
2.3.4.5:80      others.example.net (/etc/apache2/sites-enabled/others.conf:1)
2.3.4.5:443     others.example.net (/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.

About these ads

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

Comments are closed.