How may I enable all the Virtual Hosts in Apache Web Server and know if they are enabled or not?
-
That does not appear to be a question about Ubuntu. Seems the question would be better asked here. httpd.apache.org/support.html– DavidApr 7, 2021 at 7:53
-
you are right however --> After googling it a bit more I have found out that a few different ways are out there to list them all but the one that works on Ubuntu is : sudo apache2ctl -S. Every bit of the syntax must be as-is or you will get an error, so I feel it should remain here, but may be I should edit the question to include Ubuntu server in the title. I as an Ubuntu user, I always come here first and had someone asked it here, it would have saved me about 30 minutes which is a lot given that I am at work.– MaxApr 7, 2021 at 8:16
-
1Did not ask you to remove it. I suggested that you might get an answer at other site.– DavidApr 7, 2021 at 8:18
Add a comment
|
3 Answers
On Ubuntu this version works best and produces a list of all sites enabled and their aliases
sudo apache2ctl -S
You can also run below one liner script for listing all enabled current hosted webiste in ubuntu apache. this will show output accordingly.
cd /etc/apache2/sites-enabled/ && echo -e "\nListing all enabled website and its home directory for server $(hostname -I):-\n$(cat $(ls) |grep -i 'ServerName\|DocumentRoot')\nReport Timestamp:- $(TZ='Asia/Kolkata' date)\n"
If you need more details, what @Max suggested is a very good solution:
sudo apache2ctl -S
However, if you need brief info, you can use this:
sudo a2query -s