How to create virtual host in Linux

In linux if we want to work with any project we need to keep that project into /var/www this mean the localhost in linux platform. By this way we can run this into web browser by typing localhost/ [Folder name] 

We can also create a virtual host to do work with different project with different host which means virtual host.To do this we need to make a project folder into our /var/www/ [Folder name as project name] 

Suppose, the configuration Host name is and local IP address is Type following command in terminal –

Add following lines in configuration file –

Save and close it. Now create a symbolic link of this configuration file to /etc/apache2/sites-enabled directory in order to enable it type following line into terminal-

Now, add a virtual domain with a specific local IP to hosts file that is located in /etc/hosts. You can also add the port using a colon with the IP.

Add this line

Save and close it. Almost done. Finally, restart the apache service.

One thought on “How to create virtual host in Linux

Leave a Reply

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