Setting up Virtual Host

Few days ago, while working on a project, I was in need of a vhost/virtual host. Then, I searched Google and found so many answers. I just didn’t know which one to try. All of them seems important. While working on my favorite lappy I tried most of those and now I forgot the places I edited.

However, I got a small process to make the thing done. I guess, when ever Name-based Virtual Host Support is needed, it’s gonna work.

I’ll be telling about *nix system.

From terminal.

sudo gedit /etc/apache2/httpd.conf

A new window is supposed to be visible. Go to the end of the file and paste the following lines or you can modify as needed.

<VirtualHost *:80>
	DocumentRoot /www/shaon

Then save and close this one and type on terminal,

sudo gedit /etc/hosts

put this your desired name for vhost just after localhost.	localhost

Now restart apache by typing

sudo /etc/init.d/apache2 restart

Name-based Virtual Host is now ready to go. 🙂 Check it on your browser.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s