Apache Configuration Tip

I was setting up my dev environment again on my laptop (really, starting over and redoing things...long story). Anyway, I like to use Apache with ColdFusion locally, and then setup named virtual hosts for all of my projects, like this:

http://localhost/
http://cfquickdocs/
http://blog/

It's really handy. Well, Apache made some changes in the config file that tripped me up a bit. Normally I go into the http.conf file, and look for <VirtualHost, and then copy their example. Well, in this version of apache (version 2.2.8), they have moved things around a bit. It looks like they have allowed you to separate things out of the main config file, and put virtual host configurations in the /conf/extras directory. Well, I didn't really like this because I don't mess with Apache very much, and the next time I need to edit virtual host configs down the road, I might not find them (if they aren't in the main http.conf file).

So I decided to put the virtual host definitions in the main file anyway to see if it would work. At first it didn't work, my attempts to go to http://cfquickdocs/ just went to the default root site. After some digging around, I found out that you have to move the "NameVirtualHost" directive to the main http.conf file as well. They had moved this into the /conf/extra/httpd-vhosts.conf as well, so I just copied it to the main conf file, and after an Apache restart, all worked as planned. :)

Comments
You shouldn't have to "move" anything. Just uncomment.

This line:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

Should be:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Note the missing # at the beginning. Apache 2.2 just makes things a little modular. It's like a cfinclude. :)
# Posted By Todd Rafferty | 4/4/08 2:21 AM
I made the upgrade a while back and found the same thing. I didn't fight it though and just left them separated. But here's what I do so I don't have to hunt when I need to add a new site. Rt-click on file, create a shortcut and put it in My Docs\_Apache Config.

Then I can access them easily from Start -> My Docs -> _Apache Config. I also put a shortcut to the hosts file there. Of course this is assuming a Windows setup, but a similar deal could be done with Mac alias files.
# Posted By Matt Williams | 4/4/08 6:12 AM
@Todd,

Yeah, I saw that line too, but I like I said in my post, I prefer to keep them separate.

@Matt,

Yeah, I should setup shortcuts like that as well, but I'm too lazy. :) It's only once in a blue moon that I actually get in and modify the config...
# Posted By Jake Munson | 4/4/08 10:33 AM
@ Todd again...

Oops, I meant to say I prefer to keep it all in the same file.
# Posted By Jake Munson | 4/4/08 10:35 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner