Let me explain virulhosts creation by taking example. Lets say you want to create an virualhost for mylocalsite.com.
Follow as step below:
- Create a directory with name mylocalsite in your WAMP root folder.
i.e: c:\wamp\www\mylocalsite - Now create a logs directory into it.
i.e: c:\wamp\www\mylocalsite\logs - Use Notepad (or your desire text editor) to open file httpd.conf in folder C:\wamp\bin\apache\Apache2.2.11\conf and find these lines:
#Include conf/extra/httpd-vhosts.conf
and uncomment it as below(i.e remove # in front of line)
Include conf/extra/httpd-vhosts.conf - Now open C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
in notebook. And add following code into it:NameVirtualHost *:80
<VirtualHost *:80>
ServerName http://www.mylocalsite.com
ServerAlias mylocalsite.com mylocalsite http://www.mylocalsite.com
DocumentRoot C:/wamp/www/mylocalsite/
ErrorLog C:/wamp/www/mylocalsite/logs/error.log
CustomLog C:/wamp/www/mylocalsite/logs/access.log common
</VirtualHost><VirtualHost *:80>ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog C:/wamp/www/logs/error.log
CustomLog C:/wamp/www/logs/access.log common
</VirtualHost> - Now open your host file. It is located at C:\windows\system32\drivers\etc. Add following line at the bottom of the file.
127.0.0.1 localhost
127.0.0.1 www.mylocalsite.com - Now restart wamp to take effect.
- Now enter http://www.mylocalsite.com or mylocalsite.com or mylocalsite in your browser URL and see the magic.
Drop me comment if you have any problem. I will surely help you.
Posted by sham shriwastav on January 10, 2012 at 12:14 AM
its really nice to learn creating virtual host on wamp.
thanks for sharing this
sham