How to setup Virtual Host in WAMP under windows

First off all you need to open three files

1>C:\wamp\bin\apache\apache2.2.6\conf\httpd.conf
2>C:\WINDOWS\system32\drivers\etc\hosts
3>C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf

————————-Step 1——————-

OPEN : C:\wamp\bin\apache\apache2.2.6\conf\httpd.conf

#LoadModule vhost_alias_module modules/mod_vhost_alias.so
Replace with
LoadModule vhost_alias_module modules/mod_vhost_alias.so

and

#Include conf/extra/httpd-vhosts.conf
Replace with
Include conf/extra/httpd-vhosts.conf

i.e.allow for httpd-vhost enable by removing #

and

————————-Step 2——————-
Open : C:\WINDOWS\system32\drivers\etc\hosts
You will find so set yoursite.com at bottom.

127.0.0.1       localhost
127.0.0.1       yoursite.com
 

————————-Step 3——————-
OPEN : C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
Comment out whole above lines by adding # to each lines
e.g.

#
	#ServerAdmin webmaster@shop.annet22.com
	#ServerName shop.annet22.com
	#DocumentRoot "C:\wamp\www\shopannet"
#

Do not forget that NameVirtualHost *:80 must be enabled(i.e not have # in front of it)

Its looks like


NameVirtualHost *:80

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "C:\wamp\www"
</VirtualHost>

<VirtualHost *:80>
    ServerName yoursite.com
    DocumentRoot "C:\wamp\www\yourfoldername"
</VirtualHost>

————————-Step 4——————-
Finally check following ‘Apache modules’ are enabled in
alias_module
vhost_alias_module
rewrite_module

(click on wamp icon)–>Apache–>Apache Modules–>Tick all required modules
Restart WAMP
Check your browser by adding link

Yoursite

if it shows blank folder on browser YOU got success
Or
you also can check it by
Run–>cmd–>ping http://yoursite.com -t –>it must show address 127.0.0.1

NOTE:
This is having some BUGS in WAMP.
if you want multiple host on WAMP it is little difficult to handle it.
at a time only one VH is served
if you want another then comment previous VH and add new then Restart WAMP and vice-versa

Share on Facebook