删除日志文件后,apache服务无法启动

分享于 

4分钟阅读

互联网

  繁體

问题:

我删除了整个日志文件目录。


 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)




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 这将创建文件夹,并为它设置最低权限。


答案2:

用root身份运行以下命令,重新创建它:


touch /var/log/httpd/error_log



然后重启apache。



文件  STA  files  服务  log  Apache