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/” (use your version of Apache here)

You need to remove the # comment before this line:

# Include conf/extra/httpd-vhosts.conf

The next thing to do is add in a new site under ‘Apache -> Alias Directories’. When that’s done you’re ready to add in this:

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

<VirtualHost *:80>
 ServerAdmin "your@email.com"
 DocumentRoot "C:/www/my_projects/website1/"
 ServerName mydomain.dev
 ServerAlias www.mydomain.dev
</VirtualHost>

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

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 *