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.
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> ServerName www.shaon.com DocumentRoot /www/shaon </VirtualHost>
Then save and close this one and type on terminal,
sudo gedit /etc/hosts
put this your desired name for vhost just after localhost.
127.0.0.1 localhost 127.0.0.1 www.shaon.com
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.