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.

5 responses to “Using Local VirtualHosts On Apache 2.0.x”.

  1. Setting Up Multiple Apache Local Web Sites On Your Computer - HTNet Says:

    [...] Update: This guide is for Apache 1.3.x. To get local VirtualHosts to work with Apache 2.0.x, please click here. [...]

  2. Phillip Plante Says:

    I want to have multiple web pages being served under apache 2.2 but everything I’ve tried to do with httpd seems not to work 403 error denied on the site or just serves the orginal page. This includes your advice on how to do this also. Can you help me resolve this problem please. I can email you my httpd to look at if it helps. Thanks for your time Phillip

  3. Tom Says:

    To Phillip: Try checking your firewall settings and make sure you have port 80 open. I had problems with 403 error even trying to connect to localhost as well as other computers on the network (Windows).

  4. Tom Says:

    To Phillip: Little late but might help other people. Try checking your firewall settings and make sure you have port 80 open. I had problems with 403 error even trying to connect to localhost as well as other computers on the network (Windows).

  5. David Says:

    I run Apache 2.0 on Windows XP and I don’t have to do either of those. I just do this:

    ServerName …

    And it seems to work just fine.

Have Your Say