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:
- 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 - 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.










September 19th, 2007 at 2:51 pm
[...] Update: This guide is for Apache 1.3.x. To get local VirtualHosts to work with Apache 2.0.x, please click here. [...]
September 25th, 2007 at 3:25 pm
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
March 9th, 2008 at 1:25 am
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).
March 9th, 2008 at 1:26 am
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).
June 14th, 2008 at 8:20 am
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.
June 16th, 2009 at 1:15 am
i tried your additions and no go. i can email httpd.conf if u have time to look at it. i had one site working and now i’ve added another and neither work and apache won’t load. error log says:
NameVirtualHost *:80 has no VirtualHosts
[Fri Jun 12 13:26:00 2009] [warn] VirtualHost 127.0.0.1:80 overlaps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Fri Jun 12 13:26:00 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
thanks if u can help.
Erik
June 16th, 2009 at 1:16 am
oh yes apache 2.x xp pro
June 16th, 2009 at 1:17 am
Sure erik… email it to me: azmeen[at]htnetsol.com
June 28th, 2009 at 1:27 am
got it to work ..but what if i only want to test one php file in a vhost site ..how do i do that. i’ve tried http://ec.localhost/tables.php and i get a 404?? no index.php or index.html in site. is that the problem. it’s just a site to test files.
June 28th, 2009 at 1:31 am
It doesn’t matter if you got an index file or not. If you can’t open tables.php and you’re 100% sure it’s in the DocumentRoot; the only obvious answer is that Apache is misconfigured.
Check your logs.
October 14th, 2009 at 11:34 am
I’m using moodle website with apache,mysql,php. First,trying to install to my localhost as test site. What I’m trying to do is to insert another moodle site inside to my first install. I put another name in “C:WINDOWS/hosts/” that is localhost1 after that since we all know after installation automatically when you browse it in a browser the address is localhost that’s default right?. Now I put localhost1 and try to run apache. Before the run there is a message after a test by httpd.conf an error but no specific location were to edit that. When I try to open the browser an ERROR 403 appeared both localhost and localhost1… IDEA? HELP ME PLEASE
January 13th, 2010 at 4:08 am
Thanks, this was very useful. I always just used additional directories in my DocumentRoot and this will come in handy. Tested and worked great!
January 20th, 2010 at 11:38 pm
When I did the 1.3 tutorial, everything went to a single site.
After doing this one, every site just kicked back to wampserver homepage.