Sunday, May 04, 2008

Virtual Host Setup

To add a virtual host on your local machine (running apache), do the following two things:

1. Add a virtual host definition to your apache configuration file, like this:

<VirtualHost *:80>
ServerName sitename
DocumentRoot "/location/of/your/site/"
</VirtualHost>

2. Add a corresponding line to your HOSTS file (on my Mac, it is located at /etc/hosts).

127.0.0.1 sitename

You should then be able to access your site in any Web browser by going to:

http://sitename

This then allows you to develop locally in an environment nearer to how it will likely be deployed.

No comments: