3

How may I enable all the Virtual Hosts in Apache Web Server and know if they are enabled or not?

3
  • That does not appear to be a question about Ubuntu. Seems the question would be better asked here. httpd.apache.org/support.html
    – David
    Apr 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.
    – Max
    Apr 7, 2021 at 8:16
  • 1
    Did not ask you to remove it. I suggested that you might get an answer at other site.
    – David
    Apr 7, 2021 at 8:18

3 Answers 3

3

On Ubuntu this version works best and produces a list of all sites enabled and their aliases

 sudo apache2ctl -S
1

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"
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .