How to setup virtual host in apache2 on ubuntu OS

Virtual host is one of the beautiful option, which is provided by web servers. I have already shared the snacks about XAMPP virtual host creating process. I believe that snacks was tasty and delightful for your coding life.

Here, i am sharing another tasty snacks about Apache2 server virtual host, which is default server of most of linux OS. In order to create virtual host in your linux machine with apache2 server. First you have to place your project folder under root directory (/var/www/).

Create virtual host file in below location with tags

Step 1 : Go to cd /etc/apache2/sites-available/

Step 2 : cp default

Step 3 : Open your file with following command

sudo gedit

Paste the below code into file.

<VirtualHost *:80>

    DocumentRoot /var/www/project-directory/

    ErrorLog /var/log/apache2/
    CustomLog /var/log/apache2/ common

Save and close the file.

Step 4 : Enable the site for local server

sudo a2ensite

Step 5 : Finally add to hosts file.

sudo gedit /etc/hosts

Add below line into hosts file.

Now you can go to browser and type


Popular posts from this blog

Azure Cloud service problem "The current service model is out of sync"

Creating an Image Watermark

Drupal 8 Media Library with SVG upload