我已经在 CentOS 7 VM 上安装了 http24u,但 httpd 服务无法正常启动,它会启动大约 30 秒左右,然后崩溃并显示以下消息,这对我来说没有任何意义,有人可以对此作出解释或提出任何建议吗?
日志控制
-- Unit httpd.service has begun starting up.
Jun 29 11:02:38 api01 systemd[1]: httpd.service start operation timed out. Terminating.
Jun 29 11:02:39 api01 systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Jun 29 11:02:39 api01 systemd[1]: Unit httpd.service entered failed state.
Jun 29 11:02:39 api01 systemd[1]: httpd.service failed.
Jun 29 11:02:39 api01 polkitd[811]: Unregistered Authentication Agent for unix-process:31718:120305844 (system bus name :1.1444, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_IE.UT
lines 3675-3731/3731 (END)
Apache 日志
[Wed Jun 29 11:36:18.095653 2016] [:notice] [pid 31869:tid 139893291845824] ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/) configured.
[Wed Jun 29 11:36:18.095789 2016] [:notice] [pid 31869:tid 139893291845824] ModSecurity: APR compiled version="1.4.8"; loaded version="1.5.2"
[Wed Jun 29 11:36:18.095797 2016] [:warn] [pid 31869:tid 139893291845824] ModSecurity: Loaded APR do not match with compiled!
[Wed Jun 29 11:36:18.095803 2016] [:notice] [pid 31869:tid 139893291845824] ModSecurity: PCRE compiled version="8.32 "; loaded version="8.32 2012-11-30"
[Wed Jun 29 11:36:18.095807 2016] [:notice] [pid 31869:tid 139893291845824] ModSecurity: LUA compiled version="Lua 5.1"
[Wed Jun 29 11:36:18.095816 2016] [:notice] [pid 31869:tid 139893291845824] ModSecurity: LIBXML compiled version="2.9.1"
[Wed Jun 29 11:36:18.095820 2016] [:notice] [pid 31869:tid 139893291845824] Original server signature: Apache
[Wed Jun 29 11:36:18.181331 2016] [mpm_event:notice] [pid 31869:tid 139893291845824] AH00489: Apache/2.4.20 (CentOS) OpenSSL/1.0.1e-fips Skynet configured -- resuming normal operations
[Wed Jun 29 11:36:18.181422 2016] [core:notice] [pid 31869:tid 139893291845824] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Jun 29 11:37:48.132327 2016] [mpm_event:notice] [pid 31869:tid 139893291845824] AH00492: caught SIGWINCH, shutting down gracefully
systemctl 启动 httpd
这是我在systemctl status httpd
它崩溃前所看到的内容。
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: activating (start) since Wed 2016-06-29 14:42:03 IST; 25s ago
Main PID: 32435 (httpd)
CGroup: /system.slice/httpd.service
├─32435 /usr/sbin/httpd -DFOREGROUND
├─32439 /usr/sbin/rotatelogs /var/log/httpd/error_log.%Y-%m-%d 86400
├─32440 /usr/sbin/rotatelogs /var/log/httpd/access_log.%Y-%m-%d 86400
├─32441 /usr/sbin/rotatelogs /var/log/httpd/access_log.%Y-%m-%d 86400
├─32442 /usr/sbin/httpd -DFOREGROUND
├─32443 /usr/sbin/httpd -DFOREGROUND
└─32444 /usr/sbin/httpd -DFOREGROUND
Jun 29 14:42:03 api01 systemd[1]: Starting The Apache HTTP Server...
崩溃后:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: timeout) since Wed 2016-06-29 14:43:34 IST; 38s ago
Process: 32435 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
Main PID: 32435 (code=exited, status=0/SUCCESS)
Jun 29 14:42:03 api01 systemd[1]: Starting The Apache HTTP Server...
Jun 29 14:43:33 api01 systemd[1]: httpd.service start operation timed out. Terminating.
Jun 29 14:43:34 api01 systemd[1]: Failed to start The Apache HTTP Server.
Jun 29 14:43:34 api01 systemd[1]: Unit httpd.service entered failed state.
Jun 29 14:43:34 api01 systemd[1]: httpd.service failed.
答案1
我昨天在 Centos7 上遇到了这个问题,日志中没有任何内容表明问题是什么。
我可以运行 apache,但不能从 systemctl 运行——它会持续大约 90 秒,然后才会决定启动失败并终止该服务。
我的情况是 DNS 被我不知道的新防火墙阻止了;解除 DNS 阻止解决了我的问题。
答案2
我为这个问题苦苦挣扎了几天。我的问题是我缺少以下模块:
LoadModule systemd_module modules/mod_systemd.so
将该模块添加到我的 httpd.conf 中解决了这个问题。我也在使用 prefork,但不知道使用 worker 或 event 是否会改变这种情况。
答案3
这是因为系统崩溃后 httpd pid 文件仍然存在。Systemd 仍然看到服务已启动...
在我这边我有一个这样的 ExecPreStart 选项:
ExecPreStart=[[ -f /var/run/httpd/httpd.pid ]] && /bin/rm -f /var/run/httpd/httpd.pid
也许有一个更优雅的解决方案......
答案4
我通过重新启动服务器解决了这个问题,并发现端口 80 再次被关闭!
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --reload
此后,一切又恢复正常。不过,我还是不确定事情是怎么发生的。