3

I'm using Apache2, and when reloading/restarting the server I get this warning:

apache2: Could not reliably determine the server's fully qualified domain name, using (my FQDN) for ServerName

Everything works fine, but I'm trying to figure out what's causing the error. I'm grabbing the source to see if can find it, but since my C's not very good....

Some notes:

  • If I change the system hostname, Apache uses the new hostname
  • I have a ServerName set; it's the same as the hostname
  • I have a static, unique IP - dig (hostname) returns (my ip), dig -x (my ip) returns (hostname)
  • My hosts file is correct

Versions:

Apache/2.2.9
Linux 2.6.24-23-xen x86_64
Description:    Debian GNU/Linux 5.0 (lenny)

Any ideas?

Devvyn
  • 87
  • 7
Peter Stone
  • 3,756
  • 4
  • 23
  • 14

3 Answers3

8

Are you sure you have a ServerName directive with the proper value - outside any <VirtualHost> blocks? (You also need a ServerName inside each <VirtualHost> block, of course)

When Apache gives out that error message, usually it means that it's not finding a ServerName for the server as a whole. If you do have that directive set properly, I can't imagine why Apache would still be complaining...

David Z
  • 128,184
  • 27
  • 255
  • 279
  • 2
    Hey, you're right - I didn't and that fixes it. So then does "reliably determine the fqdn" really mean "find a default/global ServerName in my config file"? – Peter Stone Apr 02 '09 at 02:52
  • 1
    @Peter Stone Apache will try to determine the ServerName with a reverse ip lookup if you don't set it in the configuration. If there is no PTR record for the ip specified, then Apache gives that error message. – guns Apr 02 '09 at 03:04
  • @guns see my original post - "dig -x (my ip) returns (hostname)". `dig -x` returns the PTR. – Peter Stone Apr 02 '09 at 03:06
  • OK, that is in fact what it means - the main site config is parsed like any other vhost in server/vhost.c: "if (!s->server_hostname) { s->server_hostname = ap_get_local_host(p); }" (ap_get_local_host prints the error). I guess it's just a slightly confusing error message. – Peter Stone Apr 02 '09 at 03:22
1

On Debian, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).

If ServerName in your vhost is my-computer.my-domain.ext make sure to copy the exact name in /etc/hosts

Caution: in the /etc/hosts file, the hostname and FQDN order must be respected. First the fqdn then the hostname and localhost at the end.

~$ echo "my-computer" > /etc/hostname
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh

You can check the change with the following lines:

~$ hostname
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext

The old hostname may still be present in the command line prompt. Just logoff then login to make it disappear.

Jay
  • 179
  • 1
  • 5
  • 18
0

For further information about setting hostname and FQDN on debian (which also prevents the warning) check this: http://movealong.org/hostname.html

Motsel
  • 518
  • 1
  • 4
  • 11