Simon Holywell

Text Post

XAMPP VirtualHosts

XAMPP

XAMPP

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:

http://gist.github.com/294730

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:

http://gist.github.com/294729

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.

View Comments
Posted on Saturday, June 14, 2008. Tagged with: virtualhostingxamppComputingInternet

Comments powered by Disqus

Simon Holywell

My name is Simon Holywell and I am a Zend Certified PHP Developer with experience working for Web agencies, marketing companies and corporate IT in Australia and the United Kingdom. When I am not developing I can be found riding my motorbike, skateboarding or snowboarding. More information about my work history can be found on my online CV.

Facebook
LinkedIn
Flickr
Twitter
del.icio.us

Previous Next