在尝试重新启动httpd服务时,系统返回以下错误信息:
[root@yunweixia.com ~]# time systemctl restart httpd Job for httpd.service failed because a fatal signal was delivered to the control process. See "systemctl status httpd.service" and "journalctl -xe" for details.
进一步检查httpd服务的状态,发现服务未能成功启动:
[root@yunweixia.com ~]# 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: signal) since Mon 2018-01-08 17:03:30 KST; 22s ago Docs: man:httpd(8) man:apachectl(8) Process: 20863 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=killed, signal=KILL) Main PID: 20863 (code=killed, signal=KILL) CGroup: /system.slice/httpd.service Jan 08 17:00:29 yunweixia.com systemd[1]: Starting The Apache HTTP Server... Jan 08 17:01:59 yunweixia.com systemd[1]: httpd.service start operation timed out. Terminating. Jan 08 17:03:30 yunweixia.com systemd[1]: httpd.service stop-final-sigterm timed out. Killing. Jan 08 17:03:30 yunweixia.com systemd[1]: httpd.service: main process exited, code=killed, status=9/KILL Jan 08 17:03:30 yunweixia.com systemd[1]: Failed to start The Apache HTTP Server. Jan 08 17:03:30 yunweixia.com systemd[1]: Unit httpd.service entered failed state. Jan 08 17:03:30 yunweixia.com systemd[1]: httpd.service failed.
解决方案
1.检查并加载mod_systemd.so模块
首先,确认/etc/httpd/conf.modules.d/00-systemd.conf文件是否存在,并检查mod_systemd.so是否已加载:
[root@yunweixia.com ~]# cat 00-systemd.conf [root@yunweixia.com ~]# This file configures systemd module: LoadModule systemd_module modules/mod_systemd.so
2.编辑httpd.service服务单元文件
如果问题仍未解决,可能需要编辑httpd.service服务单元文件。运行以下命令以编辑该文件:
[root@yunweixia.com ~]# systemctl edit httpd.service
粘贴以下内容以更新服务配置:
[Unit] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/httpd ExecStart=/usr/sbin/httpd $OPTIONS -k start ExecReload=/usr/sbin/httpd $OPTIONS -k graceful ExecStop=/usr/sbin/httpd $OPTIONS -k graceful-stop PrivateTmp=true [Install] WantedBy=multi-user.target
保存并退出编辑器后,重新加载服务定义:
[root@yunweixia.com ~]# systemctl daemon-reload
再次尝试重新启动httpd服务:
[root@yunweixia.com ~]# systemctl restart httpd.service
总结
如果mod_systemd.so模块在启动httpd服务时未正确加载,可能会导致操作超时,通过确保mod_systemd.so加载并更新httpd.service配置,通常可以解决这些启动失败的问题。
原创文章,作者:运维侠,如若转载,请注明出处:https://www.yunweixia.com/solutions/httpd-restart-failure-troubleshooting-guide.html