apachectl -S: Show Apache Virtual Hosts
apachectl -S parses the config and prints the virtual host mapping, showing which IP, port, and ServerName each vhost binds.
When the wrong site answers a request, -S shows exactly how Apache resolved its vhosts. It also flags overlapping ServerName entries that silently shadow each other.
What it does
apachectl -S (equivalent to httpd -S or -t -D DUMP_VHOSTS) runs the config test and prints the VirtualHost mapping: each listening address and port, the default vhost, the named vhosts under it, and the source file and line for each. It surfaces overlap warnings when two vhosts claim the same name.
Common usage
apachectl -S
httpd -S # RHEL/CentOS
apache2ctl -S # Debian/Ubuntu
# combined with modules
apachectl -t -D DUMP_MODULESOptions
| Command / Flag | What it does |
|---|---|
| -S | Dump the virtual host configuration (implies -t) |
| -t -D DUMP_VHOSTS | Explicit form of the vhost dump |
| -t -D DUMP_MODULES | List compiled-in and loaded modules |
| -M | Shorthand to dump loaded modules |
| -V | Print version and build settings |
In CI
Use -S in a smoke stage to assert the expected ServerName resolves to the expected vhost, catching config merges that accidentally shadow a site. Because -S runs the full config test, a non-zero exit also flags a broken config.
Common errors in CI
"[warn] _default_ VirtualHost overlap on port 443, the first has precedence" means two vhosts bind the same address and port with no distinguishing ServerName. "VirtualHost ... has no VirtualHosts" indicates a misconfigured NameVirtualHost setup. Any Syntax error surfaces here first because -S implies -t.