For create a virtual host in ubuntu please follow the below step by step process.

Virtual host name is : “”
Document root for that virtual host : “/var/www/dating”

1. Create a file with name of your virtual host(name you want for your virtual host like “”) on “/etc/apache2/sites-available/”.

2. Write the following code on that file :



DocumentRoot /var/www/dating
CustomLog /var/log/apache2/ combined
ErrorLog /var/log/apache2/


3. Now you have to enable this virtual host. To do so please go to your terminal and type following command

sudo a2ensite

To disable a virtual host use following

sudo a2dissite

where is the name of the virtual host you want to enable/disable.

4. Now apache is almost ready to restart, but before doing so, we must inform our linux system that and are not to be looked for on the net, but on the local machine instead.
To do so, simply edit “/etc/hosts” and add the new host names at the end of the line beginning by, which is localhost like below :

5. And now we are done, simply reload apache by following command :

sudo /etc/init.d/apache2 reload

Open your web browser and enter the following address Magic, it runs the same as when you were using http://localhost/dating but it is far more usefull when devellopping a web service and want to be able to develop applications on your machine just like it is where the real web site.

Tagged with:  

2 Responses to How to create a virtual host in ubuntu?

  1. Cherise Blatter says:

    geiler Artikel…wo ist der Facebook button? :-)

  2. Stanton Bhat says:

    geiler Artikel…wo ist der Facebook button? :-)

Leave a Reply