list all virtual host apache

How to List All Virtual Hosts in Apache

Virtual hosts allow you to run multiple websites on a single web server. Sometimes you may need to list all virtual hosts in Apache web server to understand how many virtual hosts are supported, and locate their configuration files. Here’s how to easily list all Virtual Hosts in Apache.

 

How to List All Virtual Hosts in Apache

Virtual hosts are useful to run multiple websites, micro-sites and subdomains on a single web server. However, it can be difficult to find out the virtual host configuration details for each website, since all virtual host configuration files are located in same folder (e.g /etc/apache2/sites-enabled in Ubuntu/Debian)

Bonus Read : How to Enable TLS 1.3 in Apache

 

It is very easy to list all Virtual Hosts in Apache. Just open terminal and run the following command depending on your Linux system.

# apache2ctl -S   [On Debian/Ubuntu]
# apachectl -S    [On CentOS/RHEL]
OR
# httpd -S

 

Bonus Read : How to Install Varnish in Apache

 

You will see a similar output

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server ip-172-30-0-208.us-west-2.compute.internal (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost ip-172-30-0-208.us-west-2.compute.internal (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost blog.ubiq.co (/etc/apache2/sites-enabled/blog.conf:1)
         port 80 namevhost articles.ubiq.co (/etc/apache2/sites-enabled/articles.conf:1)
         port 80 namevhost resources.ubiq.co (/etc/apache2/sites-enabled/resources.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

The above output clearly lists the IP addresses and ports used for each virtual host’s configuration file location and its URL.

This is very helpful in finding out the configuration details of your virtual hosts and debugging them in case of issues.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

mm

About Ubiq

Ubiq is a powerful dashboard & reporting platform for small & medium businesses. Build dashboards, charts & reports for your business in minutes. Get insights from data quickly. Try it for free today!