Here are some hints for those of you that use a XAMPP install for testing your developments on your local machine.

I am using a Windows machine running XP Pro and this is how I setup my VirtualHosts. The conf file you need to amend is located at c:\xampp\apache\conf\extra\httpd-vhosts.conf Open it up in your favourite editor and un-comment the following line near the top of the file:

NameVirtualHost *:80

This will enable the creation of VirtualHosts in your XAMMP installation.

Firstly you need a VirtualHost setup for localhost so that you can access the XAMPP scripts and demo files and any projects you might already have in the default htdocs location. This will look something similar to this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot c:\xampp\htdocs
    ServerName localhost

Now for your custom VirtualHost. This can be placed anywhere on your computer where there are read permissions setup. It does not have to fall under the standard XAMPP htdocs folder. It will look something like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot c:\xampp\\pub
    ServerName simonholywell.localhost
    <Directory c:\xampp\\pub>
        Order allow,deny
        Allow from all

You will notice that in the above example there is a directory directive applied to the VirtualHost where there wasn’t one in the standard localhost VirtualHost we setup first. This is because the default install of XAMMP does not allow us to have folders outside of the DocumentRoot (c:\\xampp\\htdocs). The VirtualHost I setup was in c:\\xampp however so I had to allow Apache access in the VirtualHost container.

Don’t forget to add your new ServerName to your hosts file. Usually found in c:\\WINDOWS\\System32\\drivers\\etc\\hosts and editable with any text editor. Of course it goes without saying that Apache must be restarted after any configuration changes and you may need to restart your browser after some changes to the hosts file.