How to create apache virtual hosts in apache2(Ubuntu)

The layout of apache configurations in rehat distros and debian distros are entirely different. I’m here explaining how to create a virtual host in ubuntu.

In your home directory create a ‘public_html’ folder and create sub directories as follows.

And then create a sample test.html file in public_html directory. Make sure that the public_html directory has be read and executable permissions.

Now we need to add virtual host entry in sites-available directory.


Now we need to enable the site.

Then restart the apache

If you are creating this in your local machine add appropriate entry in /etc/hosts file


Then navigate to it will show the test file contents.<!> And your virtual host is working fine.