Setting Up a Virtual Host on WAMP

One of the biggest pains about developing on a local server setup like WAMP is that the root filepaths are different when you go live. To get around this I always set up a virtual host so that my development url can be something like, http://myapplication.localhost/. It’s really easy to set up.

First, go into the WAMP menu under the Apache section, open up httpd.conf. Go all the way to the bottom and put in this:


<VirtualHost *:80>
ServerName myapplication.localhost
DocumentRoot c:/wamp/www/myapplication/

<Directory c:/wamp/www/myapplication/>
DirectoryIndex index.php
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Changing “myapplication” to the name of the directory of your project, of course. Next, open up your hosts file (I create a shortcut on my desktop because I can’t ever remember where it is.) On my machine (Windows 7) it’s in C:\Windows\System32\drivers\etc. Add this line to the end:


127.0.0.1 myapplication.localhost

Restart WAMP and you should now be able to access it at http://myapplication.localhost.

This entry was posted in Tutorials and tagged . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>