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.
Such virtual hosts will only be used for HTTP requests received on connection to the specified IP address. However, it is additionally useful to use. on systems where the IP address is not predictable - for example if you have a dynamic IP address with your. A virtual host is used for hosting multiple domain names on a single server. This means different websites share the same server and utilities for their desired project. The Number One HTTP Server On The Internet ¶ The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
In Apache (httpd) virtual hosts are used to host web content for multiple domains off of the same server depending on the IP address or domain name that is being used. Depending on the request received different virtual host configuration can apply, resulting in different settings and web content being served from a single web server.
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.
You will get a list of all configured virtual hosts as well as another important apache/httpd server configurations.
List Apache Virtual Host Configurations
Http Hostname
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.
If you have any questions relating to Apache HTTP server, use the comment form below to reach us.
![Host Host](/uploads/1/3/4/4/134492095/168496560.jpg)
The excerpts below show some example name-based VirtualHost configurations that can be used in Apache. For more detailed instructions, please see the official documentation.
For each TCP port that you want to use to serve content, you will need to define a Listen directive before configuring your VirtualHosts. When using Apache version 2.2.x or lower, each port will also need a NameVirtualHost directive.
Basic setup, using port 80, with custom log files
Basic setup, on port 80, with multiple virtual hosts
Http Host Header
Basic VirtualHost with custom log files and authentication
SSL-enabled VirtualHost with custom log files
Httpd Virtual Host Configuration
Warning: If you want to run multiple SSL vhosts on a single IP, see this article.