This guide will show you how to quickly set up a new website in Apache 2 using virtualhosts. Follow these instructions exactly as written, down to the character: trailing slashes, case, line breaks, etc.

Start by firing up a terminal, and creating a folder for the new website:

mkdir /var/www/

I like to name Apache folders after the actual website URL, to decrease potential confusion down the road.

Next, we will copy the default Apache2 virtualhost configuration file, renaming it to your domain:

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

And open that file in your favorite text editor:

sudo nano /etc/apache2/sites-available/

Make sure your email address is correct:


Below the ServerAdmin directive, add two lines. Notice the www before the ServerAlias directive:


Now change the DocumentRoot:

DocumentRoot /var/www/

Also change the Directory directive’s path:

<Directory /var/www/>

You can now save this file and exit it.

Back in the terminal, type:

sudo a2ensite
sudo service apache2 restart

Upload your website files into the /var/www/ folder, using your favorite FTP client.

Then go to and your website will be online.

It’s that simple!

N.B. For this to work best, follow my minimal Apache2 guide.