Apache Httpd:apr_sockaddr_info_get() failed for xxx
如题所示的错误发生在Apache的Httpd服务重启的时候,具体如下:
1 2 3 4 5 6 7 |
[root@cobbler-server ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: httpd: apr_sockaddr_info_get() failed for cobbler-server httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [ OK ] [root@cobbler-server ~]# |
发生该错误的原因是:
1. httpd的配置文件“/etc/httpd/conf/httpd.conf”中没有定义ServerName
2. 并且,/etc/hosts的配置不当。
具体如下:
1 2 3 4 5 6 |
[root@cobbler-server ~]# cat /etc/httpd/conf/httpd.conf | grep -v "^#" | grep --color ServerName [root@cobbler-server ~]# [root@cobbler-server ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@cobbler-server ~]# |
在httpd.conf中没有设置ServerName的时候,Apache会使用当前系统的主机名作为默认的ServerName。而确定主机名,Apache会查看hosts表。
基于以上的问题原因,解决方法有两个:
1. 不在乎httpd.conf没有ServerName的状态,去修改hosts表
2. 不在乎hosts表配置不当的状态,为httpd.conf新增ServerName的说明
一、通过修改hosts表解决该问题:
1 2 3 4 5 6 7 8 9 |
[root@cobbler-server ~]# cat /etc/hosts 127.0.0.1 localhost 192.168.184.134 cobbler-server [root@cobbler-server ~]# [root@cobbler-server ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.184.134 for ServerName [ OK ] [root@cobbler-server ~]# |
二、通过修改httpd.conf解决该问题:
1 2 3 4 5 6 7 8 |
[root@cobbler-server ~]# vi /etc/httpd/conf/httpd.conf [root@cobbler-server ~]# cat /etc/httpd/conf/httpd.conf | grep -v "^#" | grep --color ServerName ServerName cobbler-server [root@cobbler-server ~]# [root@cobbler-server ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [root@cobbler-server ~]# |
————————————
Done。