我正在使用 Apache2,当重新加载/重新启动服务器时,我收到此警告:

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

一切工作正常,但我试图找出导致错误的原因。我正在抓取源代码,看看是否能找到它,但由于我的 C 不是很好......

一些注意事项:

  • 如果我更改系统主机名,Apache 将使用新主机名
  • 我有一个 ServerName 放;它与主机名相同
  • 我有一个静态的、唯一的 IP - dig (hostname) 返回(我的ip), dig -x (my ip) 返回(主机名)
  • 我的主机文件是正确的

版本:

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

有任何想法吗?

有帮助吗?

解决方案

你确定你有一个 ServerName 具有正确值的指令 - 任何外部 <VirtualHost> 块?(您还需要一个 ServerName 每个里面 <VirtualHost> 当然是块)

当 Apache 发出该错误消息时,通常意味着它没有找到 ServerName 对于整个服务器来说。如果你确实正确设置了该指令,我无法想象为什么 Apache 仍然会抱怨......

其他提示

在 Debian 上,主机名是在启动时通过脚本 /etc/init.d/hostname.sh 设置的,该脚本使用文件 /etc/hostname。我们可以使用此文件来更新计算机主机名及其 FQDN(完全限定域名)。

如果 ServerName 在您的虚拟主机中是 my-computer.my-domain.ext 确保在 /etc/hosts 中复制确切的名称

警告: 在 /etc/hosts 文件中,必须遵守主机名和 FQDN 顺序。首先是 fqdn,然后是主机名,最后是 localhost。

~$ 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

您可以使用以下行检查更改:

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

旧主机名可能仍出现在命令行提示符中。只需注销然后登录即可使其消失。

有关在 debian 上设置主机名和 FQDN 的更多信息(这也可以防止出现警告),请检查以下内容: http://movealong.org/hostname.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top