Problems with configuration of bind (DNS) which affect Apache

1. I've been struggling to get a virtual domain to work properly with DNS but I've been trying to use a CNAME for it. Will that work?

That might work (doubtful) but it's far easier to make this work correctly with an "A" record rather than a CNAME. DNS relates names to ip addresses. Virtual hosting can be ip based but it appears that since you're using name based hosting you'd be much better off using an "A" record!

2. If I turn off HostNameLookups to reduce my server's load how can I get my logs to show the resolved names after the fact... isn't there a tool which will do that?

Many of the log analysis tools include one but so does Apache. You can set it up as a cronjob if you like. The command is:

/usr/sbin/logresolve

The syntax for this command looks like this:

logresolve [ -s filename ] [ -c ] < access_log > access_log.new

-s filename Specifies a filename to record statistics.

-c This causes logresolve to apply some DNS checks: after finding the hostname from the IP address, it looks up the IP addresses for the hostname and checks that one of these matches the original address.

3. My server keeps hanging on boot-up... and since you asked I am doing virtual hosting. What's the problem?

In most cases this happens because you've set your VirtualHost directives to point at the DNS name of the host instead of the ip address. Guess what happens if your DNS goes down?

Assume that you have this domain:

www.some.dom == 10.0.0.10

If your directive looks like this:

<VirtualHost www.some.dom>
ServerAdmin webgenius@some.dom
DocumentRoot /www/some
</VirtualHost>

Change it to this:

<VirtualHost 10.0.0.10>
ServerAdmin webgenius@some.dom
DocumentRoot /www/some
</VirtualHost>

Problem solved!

4. Here are some general tips to avoid DNS problems with Apache.

use IP addresses in <VirtualHost>
use IP addresses in Listen
use IP addresses in BindAddress
ensure all virtual hosts have an explicit ServerName
create a <VirtualHost default:*> server that has no pages to serve