Archive for the ‘ Virtual Host ’ Category

Simple steps to setting up virtual host host on Ubuntu Server

Virtual host is a virtual environment over the top of your current web server to simulate a separate hosting environment. Using virtual host you can enable site specific features and keep your development environment totally separate from another one.

For tutorial you need to mod_rewrite enabled.

Step 1: setup hosts file

open /etc/hosts and add a virtual domain with a specific local IP.

Lets assume that our virtual domain name is “” and It will listen to the ip “″

so on /etc/hosts file we will add

now whenever you browse your browser will actually hit

Step2: configure virtual host with apache
Now goto /etc/apache2/sites-available and create a file named “

sudo touch ruzdi
sudo gedit /etc/apache2/sites-available/ruzdi

write the following contents inside. but please note to create the appropriate directory before linking your virtual host with that, for example we’ve create a folder named “/var/opt/ruzdi” and linked that directory as my document root in the following configuration file.

        DocumentRoot /opt/ruzdi
        <Directory /opt/ruzdi/>
                Options FollowSymLinks
                AllowOverride All


now create a symbolic link of this file to /etc/apache2/sites-enabled directory as “

sudo ln -s /etc/apache2/sites-available/ruzdi /etc/apache2/sites-enabled/ruzdi

**** here look directory location is /opt/ruzdi so you must create a directory named “ruzdi” on /opt location

Step 3: restart apache

simple, either one of the followings

sudo a2ensite ruzdi


sudo /etc/init.d/apache2 restart

now on your browser to http://

***This is post is similar Hasin Hyder blog post I just change a little. In my case on the hosts file port was not working so I removed it and I got everything all right.

source :


Hasin Hyder