If you have to troubleshoot any Apache issues, it is always a good idea to start with checking of the currently enabled Virtual Hosts.
This can be done with the -S
option used on the httpd/apache2
or on the apachectl/apache2ctl
.
-S
option shows which ports and which IP addresses or domain names are configured for each website being served, shows where the configuration file for each VirtualHost is located and performs a syntax check.
Get a List of All VHosts in Apache
Use one of the following commands to get a list of all VHosts in Apache on RHEL
, CentOS
, Fedora
etc.:
$ httpd -S $ apachectl -S
List All Virtual Hosts Served by Apache2
Use one of the following commands to list all Virtual Hosts served by Apache2 on Ubuntu
, Debian
, Linux Mint
etc.:
$ apache2 -S $ apache2ctl -S
In the output of the above commands you’ll see all currently enabled Virtual Hosts and the result of a syntax check:
VirtualHost configuration: 1.2.3.4:80 is a NameVirtualHost default server default (/etc/apache2/sites-enabled/default.conf:1) port 80 namevhost example.com (/etc/apache2/sites-enabled/example.conf:1) port 443 namevhost example.com (/etc/apache2/sites-enabled/example.conf:15) Syntax OK