Using Local VirtualHosts On Apache 2.0.x

I decided to revisit one of my older posts; Setting Up Multiple Apache Local Web Sites On Your Computer; which was written as a guideline for Apache 1.3.x for both Linux and Windows machines.

I’ve always used Apache 1.3.x for my web development needs (yeah, I’m old school), but this time around though, I need to get some testing done Apache 2.0.x because it’s what one of the server I’m developing for runs.

After downloading the necessary Windows installer for Apache 2.0.x (yes, I’m assigned a Windows XP notebook at work) one thing I discovered almost immediately is that the tips I’ve mentioned in my earlier post doesn’t work on Apache 2.0.x right off the bat.

After reading some of the comments in my original post, as well as reading through the Apache 2.0 manual, and bouts of experimenting I found out that the following changes are necessary for VirtualHosts to work properly:

  1. Define the NameVirtualHost 127.0.0.1:* directive: If this line is commented or non-existant in httpd.conf, your local VirtualHosts won’t work
  2. Include the hostname in the VirtualHost container. For example: <VirtualHost localtest>. If you want the VirtualHost to listen to other ports, use this example (of listening to port 8080)<VirtualHost localtest:8080>

That’s pretty much it. Migrating my Apache 1.3.x sites to Apache 2.0.x was a breeze.

Leave a Reply