【问题标题】:Why won't httpd restart after a simple change?为什么简单更改后httpd不会重新启动?
【发布时间】:2019-01-04 21:28:04
【问题描述】:

Oracle Linux 7.2

我在 httpd.conf 文件中更新了特定域的 SSL 证书。 然后我做了一个'sudo service httpd restart',它挂了很长时间(超过一分钟),然后出错了。现在,我无法重新启动 httpd,并且在 'systemctl status httpd.service' 或 'journalctl -xe' 中看不到任何提示。

这是我所看到的:

[oracle@secure-web-server-dvl ~]$ sudo service httpd start
Redirecting to /bin/systemctl start  httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[oracle@secure-web-server-dvl ~]$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-01-04 16:22:31 EST; 37s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 3299 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 3297 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 3297 (code=exited, status=1/FAILURE)

Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: Starting The Apache HTTP Server...
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com kill[3299]: kill: cannot find process ""
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: Failed to start The Apache HTTP Server.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: Unit httpd.service entered failed state.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service failed.
[oracle@secure-web-server-dvl ~]$ journalctl -xe
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID 1 has been created for the user oracle.
--
-- The leading process of the session is 3259.
Jan 04 16:22:15 secure-web-server-dvl.nitssolutions.com systemd[1]: Started Session 1 of user oracle.
-- Subject: Unit session-1.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-1.scope has finished starting up.
--
-- The start-up result is done.
Jan 04 16:22:15 secure-web-server-dvl.nitssolutions.com systemd[1]: Starting Session 1 of user oracle.
-- Subject: Unit session-1.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-1.scope has begun starting up.
Jan 04 16:22:15 secure-web-server-dvl.nitssolutions.com sshd[3259]: pam_unix(sshd:session): session opened for user oracle by (uid=0)
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com sudo[3281]:   oracle : TTY=pts/0 ; PWD=/home/oracle ; USER=root ; COMMAND=/sbin/service httpd st
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com polkitd[618]: Registered Authentication Agent for unix-process:3282:11555 (system bus name :1.14
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com kill[3299]: kill: cannot find process ""
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com 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.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: Unit httpd.service entered failed state.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com systemd[1]: httpd.service failed.
Jan 04 16:22:31 secure-web-server-dvl.nitssolutions.com polkitd[618]: Unregistered Authentication Agent for unix-process:3282:11555 (system bus name :1.

帮助?

【问题讨论】:

  • 检查apache error_log(通常在/var/log/httpd/)

标签: apache ssl-certificate


【解决方案1】:

必须有一个进程(如仍在处理的 Web 请求)附加到 httpd 导致它无法重新启动。 我在您的错误消息中看到 ID 为 3299 的进程正试图被杀死,但失败了。 检查此进程是否正在使用

ps -ef | grep 3299 

或使用

ps -ef| grep apache

参见 ma​​n ps

这将向您显示查看当前进程快照的手册

如果你发现进程仍在运行,那么你可以手动杀死它,使用命令

kill -9 3299

使用 -9 标志将阻止任何进程阻止杀死。

人杀

这应该允许您再次启动 httpd 服务。

警告:手动终止处理可能会损坏配置文件。 首先备份 apache/httpd 服务器的配置文件!

这个解决方案有点不正统,但作为最后的手段,有时你需要手动杀死一个被阻塞的 rouge 进程。

【讨论】:

  • 嗨,罗伊,感谢您的回复。但是,ps -ef | grep 3299、ps -ef|grep httpd 和 ps -ef|grep apache 都返回 no 进程。还有其他想法吗?
  • 想通了!!我更新了特定域的 SSL 证书,但我忽略了更新相应的密钥文件!一旦我更新了密钥文件,它就立即启动了。
  • 这是有道理的...在您的 .conf 文件的 VirtualHost 部分中加载的私钥与在同一部分中加载的 SSL 证书不匹配。搞清楚了!
  • 谢谢罗伊。我仍然是 Apache 的新手,但我认为这是一个错误,当这种情况发生时,它不会显示更具体的错误。
【解决方案2】:

好的,我想通了。我们的 SSL 证书已经过期,所以我更新了它。当我替换 httpd.conf 文件的各个 VirtualHost 部分中的证书时,我忘了也替换 SSL 证书的密钥。这导致了问题。当我返回并更新相应 SSL 证书的密钥时,Apache 立即启动。

我认为这是一个错误,当这种情况发生时,错误消息中没有根本原因的踪迹。我很幸运能够相对较快地弄清楚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多