Configuring Multiple Domains within WAMP for Local Development
Posted in web design brisbane on August 9th, 2010 by Maurice KindermannIn this tutorial we will be changing the necessary files to run multiple websites from WAMP. I’m going to keep it as simple and straightforward as possible.
Firstly you will need to download and install WAMP.
1. File Changes
In the file: C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
Find: NameVirtualHost *:80 Replace with: NameVirtualHost *
In the file: C:\wamp\bin\apache\Apache2.2.11\conf\httpd . conf
Find: #Include conf/extra/httpd-vhosts.conf and delete the #
2. Adding to your to hosts file
Location: C:\Windows\System32\drivers\etc\hosts
For Each Website you will need to insert the following: 127.0.0.1 www.domain.com.au
127.0.0.1 represents the IP for your localhost.
3. Setting up VirtualHosts on your local Apache
Location: C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
For Each Website add the following:
<VirtualHost *>
ServerName www.domain.com.au
DocumentRoot "C:/wamp/www/domain.com/"
</VirtualHost>
Once thats done, left click the WAMP icon in the start bar and click ‘Restart All Services’.
And that’s it!
Multiple Domain Website
If you have a website which run’s multiple domains, you can add Alises. This time you would add another ServerAlias for each website:
<VirtualHost *>
ServerName www.website-one.com.au
ServerAlias www.website-two.com.au
ServerAlias www.website-three.com.au
DocumentRoot "C:/wamp/www/multi-domain-website.com/"
</VirtualHost>
Note that in your host file, you will still put each www.domain.com.au for each website, as nothing special needs to be changed here.
If you want your website to be www.domain.git, or www.domain.subv, just change these accordingly in your vhosts and host file to differenciant between them. The tail end of the URL can be anything you want! Great if you have some websites which use a versioning software like git or subversion.
Lastly, your DocumentRoot specfication in your vhost’s file can be anywhere on your computer. If your C drive isn’t big enough to accomodate multiple websites, you can run them from anywhere you like, eg:
DocumentRoot D:/localhost/www.multi-domain-website.com/
No fuzz, simple walk thru. Great!
I’ve been managing dev-sites with sub folders and a whole lot of path juggling code in php to get it to translate well to customer servers.
Thanks!
Great article! Just for those interested, remember to take out those 2 dummy virtual hosts in httpd-vhosts.conf.
Also, if you’ve got other folders you still need to access, add this :
DocumentRoot C:/wamp/www
ServerName localhost
Awesome work dude.. complex things can be explained in simple ways.. just as u shown
Wow, it worked. Just took 2mins to get it up and running. Cheers mate.
No worries! Glad it worked out well for you
Hello
I have done the following.
1. uncommented vhost file include in httpd.conf
2. written following in vhost file.
NameVirtualHost *
ServerName abc.localhost
ServerAlias abc.localhost
DocumentRoot “E:/wamp/www/abc”
3. Added following in hosts file
127.0.0.1 abc.localhost
I restarted windows and wamp. I use windows 7 HP.
However, when I open abc.localhost, the firefox takes a long time to search and then finally, connection reset error.
What could it be that I am doing wrong?
Kind regards,.
Khuram
Hey mate,
I’ll assume you’ve done the two file changes and added the entry to your hosts file correctly.
DocumentRoot "E:/wamp/www/abc"Looks like you’ve forgotten the tailing forward slash after abc, so it should be:
DocumentRoot "E:/wamp/www/abc/"If your website runs off an index file it should be
DocumentRoot "E:/wamp/www/abc/index.php"Also, you have specified a server alias, which is only necessary if you are running multiple domains off the same website. Try changing it to something like:
ServerName http://www.abc.localhostDocumentRoot "C:/wamp/www/abc/"
If that still doesn’t work try adding www before the ServerName and before the website name in the hosts file.
If that STILL doesn’t work, I’ve found that if you don’t install Wamp to the C drive, it can cause problems. I haven’t tested this for about 2 years though, so I can’t be sure.
Hope that helps
.
Great Article and worked perfectly. Also, Meander365′s comment was what finished everything off and made things work exactly as should be.
Thanks again!
did exactly as described, and now both localhost and the virtual domain are generating error 403….
I’m having the same problem as Mark. For both of the sites I am trying to add I get “403 You don’t have permission to access / on this server.” I have given all users on this machine full access to the directories.
I’m running WAMP Server 2 on Windows Vista and I’ve tried Apache versions 2.2.11 and 2.2.17 with the same result.
Any insight that anyone could give on this problem would be very appreciated. Thanks in advance!
I managed to get it working!
It was necessary to add the following lines to the virtual host entry:
[code]
allow from all
order allow,deny
AllowOverride All
[/code]
Simply Great
Thank you so Much…!!!!