• Digital accessories
  • Server
  • Digital life
  • Privacy policy
  • Contact us
  1. Home
  2. Article
  3. How to List All Virtual Hosts in Apache Web Server

How to List All Virtual Hosts in Apache Web Server

Rsdaa 22/10/2021 1159

Apache virtual host configuration allows you to run multiple websites on the same server, that means you can run more than one website on the same Apache web server. You simply create a new virtual host configuration for each of your websites and restart the Apache configuration to start serving the website.

On Debian/Ubuntu, the recent version of Apache configuration files for all virtual hosts are stored in the /etc/apache2/sites-available/ directory. So, it makes really difficult to go through all of these virtual host configuration files to fix any configuration errors.

To make things easier, in this article we will show you how to list all enabled apache virtual hosts on a web server using a single command on the terminal. This method will also help you to see a few other useful apache configurations.

This is practically helpful in a scenario where you are assisting a company to fix their web server issues remotely, yet you do not know their current apache web server configurations, in regards to virtual hosts.

Read Also: How to Check Which Apache Modules are Enabled/Loaded in Linux

It will help ease searching for the virtual host of a specific website in the apache config files and assist in troubleshooting any apache issues, where you’ll, in most cases start with checking of the currently enabled virtual hosts before looking into the logs.

To list all enabled virtual hosts on the web server, run the following command in a terminal.

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

You will get a list of all configured virtual hosts as well as another important apache/httpd server configurations.

List Apache Virtual Host Configurations

VirtualHost configuration:*:80 is a NameVirtualHost default server api.example.com (/etc/httpd/conf.d/api.example.com.conf:1) port 80 namevhost api.example.com (/etc/httpd/conf.d/api.example.com.conf:1) alias www.api.example.com port 80 namevhost corp.example.com (/etc/httpd/conf.d/corp.example.com.conf:1) alias www.corp.example.com port 80 namevhost admin.example.com (/etc/httpd/conf.d/admin.example.com.conf:1) alias www.admin.example.com port 80 namevhost tecmint.lan (/etc/httpd/conf.d/tecmint.lan.conf:1) alias www.tecmint.lanServerRoot: "/etc/httpd"Main DocumentRoot: "/var/www/html"Main ErrorLog: "/etc/httpd/logs/error_log"Mutex default: dir="/run/httpd/" mechanism=default Mutex mpm-accept: using_defaultsMutex authdigest-opaque: using_defaultsMutex proxy-balancer-shm: using_defaultsMutex rewrite-map: using_defaultsMutex authdigest-client: using_defaultsMutex ssl-stapling: using_defaultsMutex proxy: using_defaultsMutex authn-socache: using_defaultsMutex ssl-cache: using_defaultsPidFile: "/run/httpd/httpd.pid"Define: _RH_HAS_HTTPPROTOCOLOPTIONSDefine: DUMP_VHOSTSDefine: DUMP_RUN_CFGUser: name="apache" id=48 not_usedGroup: name="apache" id=48 not_used

From the above output, we can clearly see which ports and IP addresses are configured for each website. We will also see each website virtual host configuration file and their location.

This comes very helpful, when you are troubleshooting or fixing any apache virtual host configuration errors or you simply want to see a list of all enabled virtual host summary on a web server.

That’s all! You might also find these following related articles on Apache web server.

3 Ways to Check Apache Server Status and Uptime in Linux13 Apache Web Server Security and Hardening TipsHow to Change Default Apache ‘DocumentRoot’ Directory in LinuxHow to Hide Apache Version Number and Other Sensitive Info

If you have any questions relating to Apache HTTP server, use the comment form below to reach us.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.


PREV: SKRIPT - forums.minehut.com

NEXT: How To Reset A Minecraft Server

Popular Articles

Hot Articles

Navigation Lists

Back to Top