Multiple Sites on WAMP

For people that use windows for their development environment, commonly they use WAMP.

WampServer is a Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database.
http://www.wampserver.com/en/

One thing that I ran into that isn’t explained clearly is how to setup multiple websites on your local environment.

This is a short run through on how to do this.

My examples call websites with the ending domain of .sdev. You can use any ending domain that you wish but try to not use ones that are real like .com or .net.

Firstly you have already installed WAMP on your computer into the default location of C:\wamp\

1. Create your website in a folder of your choice.

Example: C:\wamp\www\example1.sdev\www\

Here you can enter in a simple index.html page with the text “Example 1 works”.

2. Now create your virtual host (the apache config to setup this site on your computer) in the alias directory as a simple text file

Example: C:\wamp\alias\example1.conf

With the content:

This sets up the directory location for the website alias that you wish to use.

3. Create this alias locally

As this domain doesn’t exist, you need to setup your computer to make it look like it does so you can see the site you have built.
(This will only work for you and not other computers)

Edit your hosts file and add in the new domain with the DNS location of 127.0.0.1

Example: C:\WINDOWS\system32\drivers\etc\hosts (open in notepad)

Add the line:

4. Allow Virtual hosts in WAMP

WAMP doesn’t enable Virtual hosts by default so you need to set it up.

Click the WAMP icon in your sidebar and go to Apache then httpd.conf

Edit the line

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

to (removing the # symbol on the second line)

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

5. Restart WAMP

You need to restart WAMP when you add or change any of the vhosts for them to take effect.

Click the WAMP icon in your sidebar then “Stop All Services”.

Once it has turned red you click the WAMP icon in your sidebar again then “Start All Services”.

So if you go to your browser and type in the url http://example1.sdev you will now see the website that you created.

For any new websites that you wish to make locally you follow all the steps above missing out point 4.

Hope this helps any of you that have run into this problem.

Leave a Reply

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