Virtual Host using WAMP

Setup Virtual Host using WAMP / XAMP Server

Everyone among of us wants to make his life easy. In the same way, developers want to perform their developing tasks in a succeeded and rewarded way.  Today, I am going to share such a nice technique with you that resides in our localhost servers. We name it Virtual Host. It is a good approach to setup Virtual Host using WAMP / XAMP for all developers. Virtual hosting hosts multiple domain names on a single server (or pool of servers). vhost facilitates us to handle separately of our each local servers. It allows server to share its resources(like memory and processor cycle) without requiring all services provided to use the same host name.

We know that every website is developed locally before it is gone to be live. We use WAMP/XAMP etc in our Windows/Mac etc. Traditionally,all websites on localhost are saved in the C:wamp/www (in Windows). We access our project at localhost/my_website. But the Windows Apache MySQL PHP (WAMP) server is really powerful. Virtual host (vhost) provides several benefits:

  • Virtual Hosts (vhost) make URLs cleaner – localhost/my_website vs my_website.local.
  • vhost make permissions easier – restrict the access for single vhost on a local server vs permitting access to all sites on your local server.
  • Some applications demands a “.” in the URL (like Magento). This can be done as by editing the Windows hosts file. vhost is a best solution for this scenario.

Setup Virtual Host using WAMP :

For setting up the virtual host using WAMP, please start your WAMP and have the administrative access to all files and folders on your system. We will focus on one configuration file at a time.

Including Virtual Host Configuration File in Apache:

For accessing this file, press right-click on the WAMP icon in the system tray and select Apache | httpd.conf (Figure A).

Virtual Host using WAMP

Figure A

Or open your Apache configuration file located in

, where #.#.#  describes to the Apache’s version that you are running in WAMP.

  • Search for “LoadModule vhost_alias_module” (without the quotes) and uncomment the
    For activating it, just remove the hash sign from.
  • Now search “Virtual Hosts” (without the quotes) in httpd.conf and uncomment the
  • Save the conf/httpd.conf. But don’t forget to close.

Updating the Virtual Host Configuration File:

  • Open Apache Virtual Hosts (vhost) configuration file. This file will be in one directory down from the Apache configuration file directory in
  • Add the configuration for your new vhost. It is much difficult to cover the vhost configuration in this article, I suggest you study the documentation for Apache’s project . This documentation will explain various configuration directives.
  • I am adding for virtual host like .You can place any name instead of like clicks.local , videos.local etc and point that name to you project in www directory “c:/wamp/www/phpclicks”

  • Save the httpd-vhosts.conf But don’t forget to close.

Update Your Windows Hosts File:

    • Edit Windows’ hosts file located in C:Windows/System32/drivers/etc/hosts.
    • Add a new entry for the vhost you created in step 2 like for I am adding below entry.
  • Save and close it.
  • Now resart your WMAP’s all services, pop open a web browser and access your new virtual host. Celebrate!