Virtual Hosts Ubuntu 14.04

How to add virtual hosts on Ubuntu 14.04 on DigitalOcean with Apache server.

Start by copying the file for the domain. In terminal type:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

Open the new file in your editor with root privileges:

sudo nano /etc/apache2/sites-available/

Change the file. Of course you will substitute these credentials with your on. In total, our virtualhost file should look like this:

<VirtualHost *:80> ServerAdmin ServerName ServerAlias DocumentRoot /var/www/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Enable the Virtual Hosts file:

sudo a2ensite

Restart your Apache server:

sudo service apache2 restart