Managing multiple websites on a single server is a common requirement for developers, businesses, and hosting providers. Apache Virtual Hosts make this possible by allowing one Apache web server instance to serve multiple domains independently. Each website can have its own document root, logging configuration, and security settings while sharing the same server resources.
This guide explains how to configure Apache Virtual Hosts on Ubuntu 20.04 and host multiple websites efficiently.
Apache Virtual Hosts are configuration blocks that enable Apache to respond differently based on the requested domain name. Instead of deploying separate servers for every website, administrators can host several domains on one machine.
Key advantages include:
Before proceeding, ensure Apache is installed and your domain names point to the server’s public IP address.
The first step is creating a dedicated directory for each website. This directory acts as the document root where website files are stored.
A common structure looks like this:
/var/www/├── example1.com│ └── public_html├── example2.com│ └── public_html
Each domain receives its own folder, making website management cleaner and more organized.
Inside the document root, create a simple index.html file to verify that the website loads correctly once the virtual host is enabled.
It is also recommended to assign ownership of the website files to the Apache web server user (www-data) to avoid permission-related issues.
Once the directory structure is ready, create a virtual host configuration file inside Apache’s sites-available directory.
Each configuration typically defines:
For example, a virtual host can specify the primary domain and its www version while directing Apache to serve files from a specific website folder.
This separation allows every hosted website to maintain its own environment without interfering with others.
After creating the configuration file, the next step is enabling it.
Ubuntu provides a convenient utility that activates virtual host configurations by creating symbolic links between the sites-available and sites-enabled directories.
Before applying changes, always validate the configuration to detect syntax errors. Running a configuration test helps prevent Apache startup failures caused by incorrect settings.
If the test reports no issues, restart the Apache service to load the new virtual host configuration.
One of the biggest strengths of Apache Virtual Hosts is scalability. Adding another website simply requires:
This process can be repeated for any number of domains hosted on the same server.
For a more secure environment:
These practices improve both security and maintainability.
Apache Virtual Hosts provide a powerful and flexible way to host multiple websites on a single Ubuntu 20.04 server. By organizing separate document roots, configuring dedicated virtual host files, and following proper security practices, administrators can efficiently manage multiple domains without deploying additional servers. Whether you’re running personal projects or production websites, Apache Virtual Hosts remain one of the most effective features of the Apache web server.
Not every OSINT task needs a terminal, script, or advanced Linux setup. In 2026, many…
The best OSINT tools and frameworks 2026 are not useful only because they collect public…
Running a Minecraft Server Ubuntu environment is one of the best ways to create a…
Remote support and desktop access have become essential for businesses, IT teams, and individual users.…
If you need to Install Curl Ubuntu systems for downloading files, testing APIs, or transferring…
Machine learning developers often choose Ubuntu because of its stability, performance, and strong Python ecosystem.…