How to setup multiple websites on wamp?
Posted by: YURACH (60.55.11.---)
Date: April 29, 2013 10:19AM

I know that should be somewhere around <directory>, vhosts conf file and hosts file, but what exactly? I tried some methods in google, but many of them are from year 2009 or so and so doesnt work. If you know how to do this on these days, would you please share the knowledge with me. Thanks

Options: ReplyQuote
Re: How to setup multiple websites on wamp?
Posted by: RiggsFolly (
Date: April 29, 2013 10:31AM

Virtual Hosts are your best bet in my opinion.

HowTo: Create Virtual Hosts in WAMP


1. Create a new folder outside the wamp directory structure.
for example
but this can be on any disk drive visible to the PC running wamp

2. Create a subfolder in c:\websites for each site you want to create.
for example:

3. Edit the file C:\wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf
where x,y and z are the version numbers of apache that you actually have installed.

NOTE: If you are switching between 2 or more versions of apache this will have to be done to all your versions of apache in turn.

SUGGESTION: I like to use the format to make it obvious to me that I am dealing with my localhost development copy of a site, you may prefer another notation, thats ok, the word dev has no actual defined meaning in this case, its just my way of naming my development versions of a live site.

NOTE: Remove ot better still comment out ( using the # in column 1 ) the lines that already exists in this file. They are just examples.

example contents:
	# Use name-based virtual hosting.
	NameVirtualHost *:80

	## must be first so the the wamp menu page loads when you use just localhost as the domain name
	<VirtualHost *:80>
    	DocumentRoot "C:/wamp/www"
    	ServerName localhost
    	ServerAlias localhost
    	<Directory  "C:/wamp/www">
			Order Deny,Allow
    		Deny from all
    		Allow from
			# You would never want a remote user to see this wamp config page.

	<VirtualHost *:80>
	    DocumentRoot "C:/websites/site1"
	    Options Indexes FollowSymLinks
	    <Directory "C:/websites/www/site1">
			AllowOverride All
			Order Deny,Allow
			Deny from all
			Allow from
		    #If you want to allow access from your internal network
		    # For specific ip addresses add one line per ip address
		    #Allow from
	    	# For every ip in the subnet, just use the first 3 numbers of the subnet
	    	#Allow from 192.168.0
	    	# If you want to allow access to everyone
	    	#Allow from all

Add as many <VirtualHost> as you require so each of your sites have one, changing the DocumentRoot, ServerName and any other of the parameters as appropriate.
This also allows you to make SITE SPECIFIC changes to the configuration.

NOTE: This will make the wamp manager "Put Online" function no longer have any effect on these new vhost'ed sites as the security for each one is now part of the vhost definition, so leave WAMP, OFFLINE.
If you want to put one or more sites online you will have to change the Allow commands MANUALLY in the httpd-vhosts.conf file.

To check your subnet do the following:
Launch a command window, and run
Look for the line "Default Gateway" in the output and use the third number in your Allow commands.

4. Edit your httpd.conf file and search for these lines, they are near the bottom of the file.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

Remove the '#' comment character on this line to Include your newly changed vhosts, this will cause apache to register their existance.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

6. While still editing your httpd.conf file search for
	#   onlineoffline tag - don't remove
	    Order Deny,Allow
	    Deny from all
	    Allow from


Add the following after the <\Directory> tag to secure your new C:\websites folder.

<Directory "C:/websites/">
    Order Deny,Allow
    Deny from all
    Allow from

This is to set security on your new directory structure so that access to these new sites is only allowed from (localhost) unless amended from within a specific VHOST.
P.S. Your internal network will probably be something like 192.168.x.y, check your system first!

7. Now in order for your browser to know how to get to these new domain names i.e. and, we need to tell windows what IP address they are located on. There is a file called HOSTS that is a hangover from the days before Domain Name Servers (DNS) were invented. It is a way of giving nice easy rememberable names to IP address's, which of course is what DNS Servers do for us all now.

Edit your HOSTS file, this can be found in C:\windows\system32\drivers\etc , the file does not have an extension.
Windows protects this file so you must be an Administrator to be allowed to save changes to this file.

If you are using VISTA or Windows7/8 you may think you are an Administrator BUT YOU ARE NOT!!!!
So to edit this file you must launch your editor, or Notepad in a specific way to gain Administrator rights. To do this find your editors icon and launch it using the following key strokes:
Shift + Right Click over its icon, this will display a menu, click the item "Run as Administrator", and click "Allow" on the challenge dialog that will appear.

Now you are ready to edit the hosts file so navigate your editor to c:\windows\system32\drivers\etc\hosts

Add the following lines to this file
NOTE: You will need to add one line in this file for each of your new virtual hosts.

8. In order for Apache to pick up these changes you must bounce ( stop and restart ) apache.
Do this by: Wamp manager -> Apache -> Service -> Restart Service

You should now be able to use the address in your browser to get to your new sites.
Copy your sites code into the "C:/websites/xxxx" folder if you already have a site coded or,
place a quick and simple index.php file into the "c:\websites\xxxx" folder to proove it all works.

   <!DOCTYPE html>
   <html lang="en-US">
   <meta charset="UTF-8">
        echo '<div style="background-color:red;color;white;text-align:center;font-size:18px">HELLO FROM Site1</div>';

If you have used the new domain name ( ) and it has not found the site.
a. Check the changes to the hosts file.
b. Restart the "DNS Service" that runs in windows. This caches all doman names that you use in a browser so that the browser does not have to query a DNS Server each time you re-use a domain name. This may have cached your failed attempt but a restart is easy and should solve the problem and is quicker that re-booting windows, which should also work.
To do this launch a command window as an Administrator ( Shift + Left Click over the command window icon ) and run these 2 commands.

>net stop "DNS Client"
>net start "DNS Client"
Note: The quotes are required as there is a space in the services name.

Options: ReplyQuote
Re: How to setup multiple websites on wamp?
Posted by: YURACH (60.55.11.---)
Date: April 29, 2013 11:08AM




You don't have permission to access / on this server"

when trying to access vhost by its name...

I believe that maybe

<Directory "C:/websites/">
Order Deny,Allow
Deny from all
Allow from

should be writeen in some other way as they changed synthax.

any ideas?

Edited 2 time(s). Last edit at 04/29/2013 11:16AM by YURACH.

Options: ReplyQuote
Re: How to setup multiple websites on wamp?
Posted by: YURACH (60.55.11.---)
Date: April 29, 2013 11:19AM

made it to work by changing said strings to

Options Indexes FollowSymLinks MultiViews
Require local
AllowOverride All

Options: ReplyQuote

Sorry, only registered users may post in this forum.