In this post, I will walk you through, how to Setup Virtual Hosts in Ubuntu. Virtual Hosts are used to setting up more than one domain or websites using a single IP address. This is very useful if anybody wants to run multiple websites using a single IP address on single VPS.
Here are the simple steps to make virtual hosts on Apache in Ubuntu OS.
For example purpose, I am assuming that you are going to create a virtual host for “pravinh.com”.
Let’s began. The first thing that you need to create a directory to hold and serve project files.
Now give permissions to it. the above directory is owned by root user now. We should change the ownership of this directory to the regular user.
The “$USER” variable indicates the currently logged in user. Set the read permissions to the web root (/var/www/pravinh.com/html) directory, so that everyone can read files from that directory.
Now clone the default Apache configuration and create
Open the new configuration file and update the values for the ServerName, ServerAlias, and DocumentRoot. Where ServerName is the virtual host name and the ServerAlias is the www version. The DocumentRoot is the absolute path to the directory where your project is stored.
Next, enable the new virtual host configuration. If you want to disable virtual host configuration use
a2dissite instead of
Lastly, add it to the hosts file.
And add the virtual host domains one by one as shown below.
Last step but very important step restart Apache.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.