Atlantic.Net Blog

How to Set Up Apache Virtual Hosts on Ubuntu 14.04

Michael Douse
by Atlantic.Net (9posts) under VPS Hosting
Verified and Tested 02/17/15


In this article, we will go over how to add additional virtual hosts to a Linux cloud server 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. If you have not done so, follow our how-to on this here.

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:

Directory: /etc/apache2/sites-available/

Directory: /etc/apache2/sites-available/

Create a virtual host configuration file using your preferred text editor. In this example, nano is used.

nano /etc/apache2/sites-available/virtualhost.example.conf

Add a basic configuration to this file and save:

Sample Virtual Host configuration

Sample Virtual Host configuration

Some of the sections you may consider changing are:

<VirtualHost *:80>

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

ServerName virtualhost.example
ServerAlias www.virtualhost.example

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.

DocumentRoot /var/www/virtualhost.example/public_html

This will be the location of the site files for the specified domain.

Next enable the virtual host with the following command:

a2ensite virtualhost.example.conf

Your output should look like this:

a2ensite sample output

a2ensite sample output

Lastly, just restart Apache as indicated by the prompt

service apache2 reload

Congratulations! You have now successfully Set Up Apache Virtual Hosts on Ubuntu 14.04. Thank you for following along and feel free to check back with us for further updates.

More About Atlantic.Net

Atlantic.Net offers world-class hosting solutions, including VPS hosting services.

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom