How to Setup Virtual Hosts in WampServer on Windows

simple tutorial to setup multiple virtual hosts in windows using Wamp server.
First download and install WampServer in your computer.
Go to ” C:WindowsSystem32driversetc” folder. Open hosts file using any code editor such as Notepad.
Host fle codings looking like this

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#          # source server
#              # x client host
# localhost name resolution is handled within DNS itself.
#      localhost
#    ::1            localhost

add this lines at end of the file.

Code:  mysite.local    #My Test Site

and save this file.
Open”C:wampbinapacheApache2.4.4conf” location.
You can find “httpd.conf
Open “httpd.conf” using any code editor.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

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

Uncomment the line to remove # symbol like this

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

It make Apache include “httpd-vhosts.conf” file.
Go to “C:wampbinapacheApache2.4.4confextra” location.
Open “httpd.vhosts.conf” using any code editor.
add this line to allow

<Directory /wamp/www/MyProject/>
Order Deny,Allow
Allow from all

It provide Apache permission to access the filder
Next add this lines

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/MyProject/"
ServerName mysite.local

ServerName match the domain name you previously entered in Host file.
Restart WampServer using
Click “Show Hidden icons” in Windows Task bar. Left click green WampServer icon. Click “Restart All Services” option.
That’s all. Now type “http://mysite.local/ in your browser.

Leave a comment

Your email address will not be published. Required fields are marked *