Have you ever looked in the apache config files to see where a website's virtual host is defined? The apache2ctl script has a useful option that could come in good here. When you execute the command, it should look like this:
apache2ctl -S
You'll obtain a list of all virtual hosts and default servers in the shell, along with the line number where they're declared. Example:
~# apache2ctl -S VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:8080 is a NameVirtualHost default server ispconfig.local (/etc/apache2/sites-enabled/000-ispconfig.vhost:10) port 8080 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-ispconfig.vhost:10) *:8081 is a NameVirtualHost default server ispconfig.local (/etc/apache2/sites-enabled/000-apps.vhost:10) port 8081 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-apps.vhost:10) *:80 is a NameVirtualHost default server ispconfig.local (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.vhost:7) Syntax OK
Thanks to Planetfox for this tip.
Spring cleaning is not only necessary for homes, Your Linux Mint 20 file system also…
Even in this day and age of high-speed PCs, many people use detachable or linked…
Windows has significantly altered the user interfaces for the clock, calendar, and battery. While the…
To upgrade your system to the most recent version, you must have enough storage space…
You may connect your Android or iPhone to your PC and use the function on…
You won't be able to directly add folders to the taskbar in Windows 10. In…
View Comments
If only you could pipe the output from httpd -S. It's unpipable :(
"httpd -S | grep something" would be soooo useful when running a ton of sites but the output just goes to console anyway.
Charles,
It's using standard error, instead of standard out. You can redirect standard error as follows:
apachectl -S 2> allhosts.txt
Then you can grep or whatever you need to do with allhosts.txt
Regards,
-Eric ;.,
Or if you want to pipe it you can redirect stderr to stdout.
apachectl -S 2>&1 | grep something
It saves the step of sending the output to a file.
I use httpd -s. Is there a reason I should use apache2ctl -S instead?
httpd is not available on ubuntu.
apache2ctl -S | grep namevhost | awk -F ' ' '{ print $4 }'
should list all domains (tested on ubuntu 14.04-trusty)
sudo apache2ctl -t -D DUMP_VHOSTS
works in my ubunutu 16.04