Start by copying the file for the domain. In terminal type:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Open the new file in your editor with root privileges:
sudo nano /etc/apache2/sites-available/example.com.conf
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 admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Enable the Virtual Hosts file:
sudo a2ensite example.com.conf
Restart your Apache server:
sudo service apache2 restart