阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Apache启动不了httpd: apr_sockaddr_info_get() failed xgp

104次阅读
没有评论

共计 2577 个字符,预计需要花费 7 分钟才能阅读完成。

httpd: apr_sockaddr_info_get() failed for hoteel
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
我在 service httpd restart 的时候提示上述信息的。虽然启动成功了,但是也是很郁闷的。
这是因为我在配置 DNS 的时候 hostname hoteel 造成的。
重新 hostname localhost 就可以了。
我在网上找来一些有关这方面的信息,就顺便贴在这里了。
1
在启动 httpd 时出现
Starting httpd: httpd: apr_sockaddr_info_get() failed for MYHOST
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName.
这个问题应该是没有在 /etc/httpd/conf/httpd.conf 中设定 ServerName 所以它会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。
所以要解决这个问题可以设定 ServerName 或者在 /etc/hosts 中填入自己的主机名称 MYHOST,像这样:
>vi /etc/hosts
127.0.0.1 localhost.localdomain localhost MYHOST

2
在 Linux 下安装完 Apache 2.2.6,启动 HTTP 服务就报错,似乎不影响服务的使用,但是也挺别扭的。

[root@linux http]# ./apachectl start
httpd: apr_sockaddr_info_get() failed for linux(在 BSD 上是 apr_sockaddr_info_get() failed for freebsdla)
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

经分析发现是 apache 的 conf 目录下的配置文件 httpd.conf 中关于 hostname 设置和 /etc/sysconfig/network 中的 HOSTNAME 设置不统一导致的,修改成统一的主机名即可解决该问题。

注:/etc/sysconfig/network 默认主机名是:HOSTNAME=localhost.localdomain

PS:网上有这种办法,似乎是没用的,因为我认为 apache 在编译安装过程中会编译 ARP 的,因此下述操作有点多余。

apr 和 apr-util 包含在 Apache httpd 的发行源代码中,并且在绝大多数情况下使用都不会出现问题。当然,如果 apr 或 apr-util 的 1.0 或 1.1 版本已经安装在你的系统中了,则必须将你的 apr/apr-util 升级到 1.2 版本,或者将 httpd 单独分开编译。要使用发行源代码中自带的 apr/apr-util 源代码进行安 装,你必须手动完成:

# 编译和安装 apr 1.2

apr
./configure –prefix=/x/httpd/apr
make
make install

apr-util
./configure –prefix=/x/httpd/apr_util –with-apr=/x/httpd/apr
make
make install

apache
./configure –prefix=/x/httpd/apache2 \
–enable-so \
–enable-cgi \
–enable-rewrite \
–enable-mods-shared=all \
–with-apr=/x/httpd/apr \
–with-apr-util=/x/httpd/apr_util

LDFLAGS=”-L/usr/lib64 -L/lib64″

本机正确设定说明 必须为同一的

[root@linuxidc ~]# nl /etc/hosts
    1 # Do not remove the following line, or various programs
    2 # that require network functionality will fail.
    3 127.0.0.1 localhost.localdomain linuxidc

[root@spring ~]# nl /etc/sysconfig/network
    1 NETWORKING=yes
    2 NETWORKING_IPV6=no
    3 HOSTNAME=linuxidc
    4 #GATEWAY=192.168.8.1

[root@linuxidc ~]# less /etc/httpd/conf/httpd.conf|grep ServerName
# ServerName gives the name and port that the server uses to identify itself.
#ServerName www.example.com:80
ServerName 127.0.0.1

CentOS 6.5 编译安装 httpd-2.4.7 http://www.linuxidc.com/Linux/2014-02/97265.htm

httpd 中工作模型的比较  http://www.linuxidc.com/Linux/2014-03/99093.htm

源码编译安装 httpd2.4 及虚拟主机 http://www.linuxidc.com/Linux/2014-08/105384.htm

编译安装最新版 httpd-2.4 http://www.linuxidc.com/Linux/2014-03/98761.htm

httpd2.4 基本功能的实现 … http://www.linuxidc.com/Linux/2014-03/98762.htm

Apache Httpd 服务器之基础教程  http://www.linuxidc.com/Linux/2015-02/114007.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-04/116145.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计2577字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中