organized flames

Fun With Apache and Virtual Hosts

Posted on October 31, 2007 by Michael

Specifically, name based virtual hosts.

I recently tried to add IPv6 support to my web server. I used to have it, I remember having it, so this should not be all that hard.

After an hour of hacking, I ended up finding two gotchas:

  • Make certain, I mean certain, that all virtual hosts for name-based servers have a unique ServerName line.
  • Make certain, and I mean certain, to save your original configuration files.

Yea, I know, I should have known better. But this is a simple thing to change, right?

A very useful tool is apachectl -S, which lists all virtual hosts. Even better is to run that output through sort

Comments
  1. Christopher CashellNovember 17, 2007 @ 09:30 PM
    changetrack can be very useful for saving original configs. It's a small per program, usually run from cron, that goes through a list of files you give it (I usually tell it to hit everything under /etc that's a text file), and e-mails you diffs for them. It uses RCS to store everything on the backend, so if you need to, you can retreive old versions. Of course, there are dozens of other ways of doing this, including directly storing configs in [insert revision control system here], but changetrack has the advantage of being automatic, dead simple, and requiring less than 2 minutes to install. Having been bitten before on similar situations, I've gotten into the habbit of installing changetrack on pretty much any machine I manage (also usefuly in mixed environments to keep an eye on what other people are doing).
  2. David HankinsJanuary 03, 2008 @ 11:11 PM
    Wouldn't it be easier to just check the configs into RCS? I just do this habitually now, even on my home systems...no cron job perl needed.