arch linux apache 启动时启动崩溃

arch linux apache 启动时启动崩溃

我有安装了 Arch Linux 的 Raspberry Pi B+,在启动时,apache Web 服务器无法启动:

[xxx@rpi ~]# systemctl status -l httpd
* httpd.service - Apache Web Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 1970-01-01 01:00:23 CET; 45 years 0 months ago
  Process: 177 ExecStart=/usr/bin/apachectl start (code=exited, status=134)

Jan 01 01:00:23 rpi apachectl[177]: Assertion 'canonical' failed at src/nss-myhostname/nss-myhostname.c:204, function fill_in_hostent(). Aborting.
Jan 01 01:00:23 rpi apachectl[177]: /usr/bin/apachectl: line 79:   185 Aborted                 (core dumped) $HTTPD -k $ARGV
Jan 01 01:00:23 rpi systemd[1]: httpd.service: control process exited, code=exited status=134
Jan 01 01:00:23 rpi systemd[1]: Failed to start Apache Web Server.
Jan 01 01:00:23 rpi systemd[1]: Unit httpd.service entered failed state.
Jan 01 01:00:23 rpi systemd[1]: httpd.service failed.
Jan 01 01:00:24 rpi systemd-coredump[208]: Process 185 (httpd) of user 0 dumped core.
[xxx@rpi ~]#

但是,如果从 ssh 终端重新启动 apache(系统重新启动并 ssh 登录后),apache 将正常运行:

[xxx@rpi ~]# systemctl restart httpd && systemctl status -l httpd
* httpd.service - Apache Web Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2015-01-05 02:48:46 CET; 336ms ago
  Process: 420 ExecStart=/usr/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 424 (httpd)
   CGroup: /system.slice/httpd.service
           |-424 /usr/bin/httpd -k start
           |-426 /usr/bin/httpd -k start
           |-427 /usr/bin/httpd -k start
           |-428 /usr/bin/httpd -k start
           |-429 /usr/bin/httpd -k start
           `-430 /usr/bin/httpd -k start

Jan 05 02:48:44 rpi apachectl[420]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.154. Set the 'ServerName' directive globally to suppress this message
Jan 05 02:48:45 rpi systemd[1]: PID file /run/httpd/httpd.pid not readable (yet?) after start.
Jan 05 02:48:46 rpi systemd[1]: Started Apache Web Server.
[xxx@rpi ~]#

发生了什么(运行Linux octopustest 3.12.35-1-ARCH #1 PREEMPT Tue Dec 23 07:14:51 MST 2014 armv6l GNU/Linux内核和Apache/2.4.10)?

答案1

有一个非常简单的修复方法对我有用。它需要编辑 /etc/hosts 文件,如果可能的话,总是要避免这样做,但它解决了我遇到的所有问题。如果任何程序尝试访问互联网并取回信息,包括 Apache、Eclipse 和其他应用程序,就会发生此错误。这有时是由应用程序本身的错误引起的,但也可能是本地问题,这是当您的 /etc/hosts 文件缺少程序所需的某些元素时引起的。

请注意,您将需要管理员访问权限(或成为该sudoers组的一部分)才能完成其中一些步骤。

首先,使用以下命令打开主机文件:sudo nano /etc/hosts.您的主机文件应类似于以下内容,这是我的直接副本:

# 
# /etc/hosts: static lookup table for host names
#

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1   localhost.localdomain   localhost BEN-PC-ARCH
::1         localhost.localdomain   localhost BEN-PC-ARCH
# End of file

请注意,除了将 127.0.0.1 反射到 localhost.localdomain 之外,还有第二行执行相同的操作。无论出于何种原因,将其添加到/etc/hosts文件中都可以解决问题。

相关内容