Creating a Virtual Host on Apache2 Ubuntu 14.04LTS

You will need to have installed/Created:

Sudo or root access
Apache2
Folder Path Directory

1. create a virtual host for the website, by copying and renaming the default configuration file in apache

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/(exmaple.co.uk).conf

2. edit virtual host conf file

sudo nano /etc/apache2/sites-available/(example.co.uk).conf

The config file should look like this in the end:

ServerAdmin [email protected]
DocumentRoot /var/www/(example.co.uk)/html
ServerName (example.co.uk)
ServerAlias (example.co.uk)
<Directory /var/www/(example.co.uk)/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

3. enable the virtual hosts

sudo a2ensite (example.co.uk).conf

You will get the message below:

Enabling site (example.co.uk).
To activate the new configuration, you need to run:
service apache2 reload

4. reload apache

sudo service apache2 restart

All done 😀

The following two tabs change content below.

Keeran Marquis

Network Engineer
Keeran Marquis is a Network Engineer. His main goal is to learn everything within the Networking field, pick up a little bit of scripting, be a poor man sysadmin and share whatever he knows! All Posts are his own views, opinions and experiences, no guarantees they will work for you but point you in the right direction 🙂
Share this:
Share

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.