Setting up virtual hosts in WAMP

WAMP is some great software, and lets us all do our development on our own PC’s. The only downside is that as it comes configured standard, it only works with the http://localhost/ domain, which is good, but doesn’t let you keep up with multiple sites at the same time.

First off, you need to configure WAMP to accept virtual hosts. This is done by editing this file:

“C:/wamp/bin/apache/ApacheX.X/conf/httpd.conf” (use your version of Apache here)

You need to remove the # comment before this line:

# Include conf/extra/httpd-vhosts.conf

I use a directory to hold all of my alias configuration files, so I set this directory to be included in my httpd.conf file by adding this at the bottom:

# Add our alias files
Include "conf/alias/*.txt

When that’s done you create alias configuration files in this directory. With the directive above, the files have to end with the .txt xtension, so I use something like ‘site.local.txt’ as the file name.

Alias /site_alias/ "C:/www/my_projects/website1/"

<VirtualHost *:80>
 ServerAdmin ""
 DocumentRoot "C:/www/my_projects/website1/"

<Directory "C:/www/my_projects/website1/">
 Options Indexes FollowSymLinks MultiViews
 AllowOverride all
 <IfDefine !APACHE24>
 Order Allow,Deny
 Allow from all
 Require local

When that’s done, update your hosts file to point your chosen development domain to your localhost, and you’re done!

Leave a Reply

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