Setting Up Virtual Hosts On WAMP Server

Wamp Server logo

If you are installing WAMP on your Windows desktop computer, there are some things you can do to make it a better development environment and more natural to use.

Modify hosts file

In your c:/windows/system22/drivers/etc/hosts file, make the following changes:

127.0.0.1 localhost
127.0.0.1 www.iTest.com iTest.com

This will force all references to itest.com and www.itest.com to go to WAMP. For Windows 7 users, you will need to run Notepad as an administrator to change this file.

Modify httpd.conf file

Enable virtual hosts in the httpd.conf file:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Modify httpd-vhosts.conf file

Add the following to your httpd-vhosts.conf file. Replace the internal domain name with yours.

NameVirtualHost 127.0.0.1

# Default virtual host that will bring up the WampServer home page
<VirtualHost 127.0.0.1>
  ServerName localhost
  DocumentRoot "c:\wamp\www"
</VirtualHost>

# Definition for iTest.com, our virtual host
<VirtualHost 127.0.0.1>
  ServerName iTest.com

  #subdirectories and www canonical
  ServerAlias www.iTest.com *.iTest.com         

  #the physical location
  DocumentRoot "C:\wamp\www\iTest.com"

  ServerAdmin webmaster@iTest.com
  ErrorLog "logs/iTest.com"
  CustomLog "logs/iTest.com-access.log" common
</VirtualHost>

If you want to add more virtual hosts, just repeat the recipe above.


ASO ad


Filed under: