Apache Virtual Hosts in Ubuntu

In this tutorial, I’ll show you the steps to configure 3 Apache virutal hosts running on a single EC2 Ubuntu Instance. The three domains, that I’ll use in this tutorial are:

1) linuxsoft.tk
2) rbgeek.tk
3) tendo.tk

DNS setting for these 3 domains are as follows:

Create three folders inside the /var/www folder, they will host these new sites:

sudo mkdir /var/www/tendo
sudo mkdir /var/www/rbgeek
sudo mkdir /var/www/linuxsoft

Copy the /etc/apache2/sites-available/default file with the name same as the new sites:

cd /etc/apache2/sites-available/
sudo cp default tendo
sudo cp default rbgeek
sudo cp default linuxsoft

Edit the new config files for each site:

sudo nano linuxsoft

Add the line ServerName with the name of your domain/site and change both DocumentRoot and Directory that point to your new site:

Repeat these steps for other new sites same as above:



To enable the each virtual host, simply type:

sudo a2ensite tendo
sudo a2ensite rbgeek
sudo a2ensite linuxsoft
sudo a2dissite default

Finally, restart the Apache service:

sudo service apache2 restart

Test all the sites:




Hope this will help you!

Leave a Reply

Your email address will not be published.