How to: Setup Multiple Virtual Hosts in WAMP Server

WAMP, or Windows Apache MySQL PHP has been a very server for lots of PHP developers who uses Windows environment. These are mainly the freelancers who mostly uses laptops as their local development machines. Whatever may be the reason, but when you use WAMP, it becomes difficult to manage multiple application installed in same root.

For example while we use WAMP as a development environment, we have different client specific projects residing in different folders in the root and whenever these projects needs to be uploaded in production environment, the absolute paths has to be manually change.

What if we want to have different root folder for each client? Well, this is possible in WAMP using Virtual Hosts. Let us see how to setup the virtual hosts.

First we need to modify two files to create virtual hosts:

hosts file: This file is in the c:\windows\system32\drivers\etc\ folder

The hosts files has entries which maps IP Address to a name. By default the name “localhost” is mapped to 127.0.0.1 IP Address.

Now what we have to do is to simply add few more entries per client in this file. You may want to use your clients domain name as mapping key (e.g. viralpatel.local)

Add as many entries as you want in hosts file. Whenever you enter “client1.local” in your web browser, windows will first look into hosts file and if it gets the corresponding entry, it sends the request to that IP Address.

Now we have to change httpd.conf. Open the httpd.conf file and search for something like:

Add following code after the ‘DocumentRoot “c:/wamp/www”‘ entry in httpd.conf file.

The tutorial is bad practice. This is the right way to do it.
In httpd.conf uncomment
LoadModule vhost_alias_module modules/mod_vhost_alias.so
That loads up the virtual hosts file
Then in extra/httpd-vhosts.conf
add your virtual containers

But the problem is that, I have created three virtual host with test php files. The first one is working fine. Other two is taking too much time. Let me know if I need to change something in this files.