mod_unique_id:尽pipe设置了etc / hosts和Apache ServerName,但无法findFQDN的IPv4地址

我试图得到mod_security,并击中了非常常见的主机名错误

[alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "computername.domain.com"

这通常意味着在主机文件中需要一个条目。 不过,我已经尝试了主机名的所有组合; 本地主机(127.0.0.1),本地IP地址(192.168 ….)和公共IP地址(“122.56.11.156”)。 我也尝试了Apache的ServerName的所有组合; computer.domain,域名,IP地址,并没有设置它。 没有什么似乎为我工作。

目前我的/ etc / hosts文件看起来像:

 # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 computername.domain.com computername localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.0.102 computername.domain.com computername #192.168.0.102 computername.hostingprovider.local computername # NIC <eth0> #122.56.11.156 computername.domain.com computername 

平安作品,也是主机名显示

 [root@computername~]# hostname computername.domain.com 

公共dns没有计算机名作为子域,那么正确的IP地址/服务器名组合使用什么? 主机上的重复条目会发生什么? 什么mod_unqiue_id检查可能导致它失败?

感谢您的任何帮助,您可以提供


根本的问题

感谢strace的build议。 在启动Apache时,我得到了以下。

 1377 open("/etc/hosts", O_RDONLY) = -1 EACCES (Permission denied) 

如此快速的健康检查权限和:

 # ll /etc/hosts -rw-r--r-- 2 root root 608 Jul 22 16:01 /etc/hosts 

但事实certificate是SELinux ,见下文

问题是SELinux

 #less /var/log/audit/audit.log type=AVC msg=audit(1311546944.235:1040): avc: denied { read } for pid=1396 comm="httpd" name="hosts" dev=dm-0 ino=262931 scontext=user_u:system_r:httpd_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file 

在我的情况下,解决了它:

 # ls -lZ /etc/hosts -rw-r--r-- root root system_u:object_r:initrc_tmp_t /etc/hosts # setenforce 0 # restorecon -R -F -v /etc/hosts # setenforce 1 # ls -lZ /etc/hosts -rw-r--r-- root root system_u:object_r:etc_t /etc/hosts 

我正在寻找错别字和其他一些“愚蠢简单”的错误(我用我的妻子作为certificate读者),但是如果这样做不起作用, mod_security正在尝试做。 它可能不是读取/etc/hosts – 可能是通过DNS解决名称失败,而不是某种forms的硬故障,或其他。

无论如何,我会把机器的名字放在DNS中。 它只是节省了很多麻烦。