How to set up multiple sites with WAMP

Default WAMP installation configured to run only one website via localhost. Apache has Virtual Hosts directive that allows to set up more than one sites on a single server.

The following instruction assume that you already installed WAMP on your computer.

Step 1

Choose a projects directory where you intend to store all your sites and add permissions to Apache to access content in that folder. I use webprojects folder located in my documents.

To do this open httpd.conf file which you can access via WAMP menu and add the following text at the bottom of the file:

<Directory C:/Users/dvlancer/Documents/webprojects >
	AllowOverride all
	Order Deny,Allow
	Allow from all

Note that you will need to replace backslashes with front slashes in the directory path.

Step 2

Create a folder in your project directory. ie myNewWesbite

Step 3

Add a domain which will be used to access your new website. To do this open hosts file located in C:/Windows/System32/drivers/etc. You can access this file using notepad. Note you will need to run notepad as an Administrator if you are using windows Vista or Windows 7. Make sure you change Text Documents to All files in the dropdown box.

Add the following line at the bottom of the hosts file   mynewsite.local    #my new website

You can replace mynewsite.local with something more meaningful to your project using the same characters as any other domain found on the internet.

Step 4

Link the domain name you created in Step 3 to the directory you created in Step 2. To do this add the following code at the bottom of httpd.conf file. Right after the code you added in step 1

<VirtualHost *:80> 
	DocumentRoot "C:/Users/dvlancer/Documents/webprojects/myNewWesbite"
	ServerName mynewsite.local

Note that DocumentRoot has to be the same as the path of the folder you created in Step 2 and ServerName needs to be the same as the name you created in Step 3

Step 5

Restart apache via WAMP menu and you are done! go to http://mynewsite.local with a browser to check your new website.

Common errors

404 Not found error when using .htaccess

You can get this error when you are using a content management system that uses .htaccess for search friendly URL. If you do, make sure that you have mod_rewrite enabled in apachie config file and have "AllowOverride all" for the directory where your website is located

Access denied

Double check that the a DocumentRoot directory created in Step 2 is located within your projects Directory created in step 1


Would you like to contribute?

Free business joomla templates