Verified and Tested 02/17/15
In this article, we will go over how to add additional virtual hosts to a Linux VPS with Apache installed. Each virtual host handles a specific website or domain that will be hosted on the server, including sub-domains. This is referred to as named-based hosting because it allows multiple websites to utilize one set of resources, such as a single IP.
This article assumes that you have already installed Apache and performed the basic configuration of it.
Setting up Apache Virtual Hosts on Ubuntu 14.04
All sites/hosts are located in the following directory:
If you have just installed Apache, these are the only things you should see:
Create a virtual host configuration file using your preferred text editor. In this example, nano is used.
Add a basic configuration to this file and save:
Some of the sections you may consider changing are:
This is the port that this virtual host will be accessible from. If we were to change 80 to 8080 then we would type the following URL to access the host: http:// virtualhost.example:8080
These values will indicate the domain that this virtual host will be representing and the alternate name for the host.
ServerAdmin [email protected]
Update this with your applicable server admin email address.
This will be the location of the site files for the specified domain.
Next enable the virtual host with the following command:
Your output should look like this:
Lastly, just restart Apache as indicated by the prompt
service apache2 reload