我删除了整个日志文件目录。
sudo apachectl start
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@maximumroulette ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2020-07-21 15:58:15 UTC; 2s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3703 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 3702 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 3702 (code=exited, status=1/FAILURE)
Jul 21 15:58:15 maximumroulette httpd[3702]: [Tue Jul 21 15:58:15.725253 2020] [so:warn] [pid 3702] AH01574: module proxy_http_module is already loaded, skipping
Jul 21 15:58:15 maximumroulette httpd[3702]: [Tue Jul 21 15:58:15.725424 2020] [so:warn] [pid 3702] AH01574: module proxy_wstunnel_module is already loaded, skipping
Jul 21 15:58:15 maximumroulette httpd[3702]: (13)Permission denied: AH00091: httpd: could not open error log file /var/log/httpd/error_log.
Jul 21 15:58:15 maximumroulette httpd[3702]: AH00015: Unable to open logs
Jul 21 15:58:15 maximumroulette systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jul 21 15:58:15 maximumroulette kill[3703]: kill: cannot find process ""
Jul 21 15:58:15 maximumroulette systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 21 15:58:15 maximumroulette systemd[1]: Failed to start The Apache HTTP Server.
Jul 21 15:58:15 maximumroulette systemd[1]: Unit httpd.service entered failed state.
Jul 21 15:58:15 maximumroulette systemd[1]: httpd.service failed.
更新:
现在在error_log中我发现信息:
(13)Permission denied: AH00091: httpd: could not open error log file /etc/httpd/logs/ssl_error_log.
当我想启动 mongod 服务时我得到了相同的日志......
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
我在这里找到了答案: https://unix.stackexchange.com/questions/377903/can-not-restart-the-httpd-service/377932#377932
I saw your environment is development, not production.
So set the selinux permissive model can be help
Follow the steps:
# getenforce
# setenforce 0 // there will print `Permissive`
# systemctl start httpd.service
Check it :
systemctl status httpd.service
但无论如何,您的回答帮助我摆脱了困境。
答案1
你的错误是could not open error log file /etc/httpd/logs/ssl_error_log
你说你删除了整个日志文件夹;问题是虽然 Apache 很乐意创建日志文件在启动时,它不会创建文件夹。
/etc/httpd/logs
是指向 的符号链接/var/log/httpd
,因此问题是“您删除了什么?”。
执行ls -ld /var/log/httpd /etc/httpd/logs
。
您可能只会看到其中一个,而出现错误提示另一个不存在。
创建/etc/httpd/logs
执行ln -s /var/log/httpd /etc/httpd/logs
要创建/var/log/httpd
执行mkdir -p /var/log/httpd && chmod go= /etc/httpd/logs
。这将创建文件夹并为其设置最低权限。
我已将文件夹权限设置为最低,打开日志时 apache 将以 root 身份运行,因此这不是问题。稍后您可能需要或希望放宽权限。
答案2
以 root 身份运行来重新创建它:
touch /var/log/httpd/error_log
然后重新启动 apache。