Set Up Virtual Hosts On Apache Web Server In Linux Mint 14

It is quite easy to set up an Apache web server on a Linux Mint 14 system (detailed instructions here). However, you might need a more complex web server, one that can host multiple separate websites, rather than subdirectories within a larger website.

How do you do this?

Apache has a feature called “virtual hosts” that lets you run separate websites, with completely different domain names, on the same physical server. Fortunately, implementing virtual hosts for Apache on Linux Mint 14 is actually quite simple to do. In this example, we’ll show you how to set up a new website called “” on an Apache web server.

First, you’ll need to set a location for your new web site’s files. Apache, you might recall, by default stores the web files in /var/www. For this example, create a new folder for the website with this command:

sudo mkdir /var/w2

Next, you’ll need to create a configuration file for the new website in the /etc/apache2/sites-available directory. Fortunately, that directory contains a default file you can simply copy and use as a template with this command:

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/examplename

The next step is to edit the new configuration file with the correct settings. You can do this using the vi text editor:

sudo vi /etc/apache2/sites-available/examplename

(If you’re unfamiliar with vi, you can find directions in my $0.99 Ubuntu Beginner’s Guide.)

Once editing the file with vi, you’ll need to make a few changes.

Change the “Document Root” directive from /var/www to the proper location of your new website, in this case, /var/w2.

Also change the “Directory” directive from /var/www to /var/w2.

Finally, under the line that begins “ServerAdmin”, add a new line for the new website’s domain name. For our website named “”, add a line like this:


Save changes to the configuration file, and then exit vi.

Now you’ll need to modify Apache to display the new domain names to web visitors. Fortunately, you can do this with the a2ensite command:

sudo a2ensite examplename

(Note that “examplename” would change depending upon what you named your configuration file.)

One final step – restart Apache to force it to re-read its configuration files and start serving the new website:

sudo /etc/init/d apache2 reload

Make sure you have some sort of index.html file in /var/w2, and the website should now be working.



The Linux Command Line Beginner’s Guide.

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide.

This entry was posted in Linux Mint 14. Bookmark the permalink.