apache启动报错`Job for httpd.service failed...`的修复

前言

可道云网盘用的apache,现在磁盘内存爆满了,导致经常错误,重启也失败。

故障现象

重启httpd时报错

1
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

按提示输入

1
journalctl -xe

输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- The start-up result is done.
3月 07 22:43:20 localhost.localdomain sshd[2224]: pam_unix(sshd:session): session opened for user wenger by (uid=0)
3月 07 22:43:44 localhost.localdomain sudo[2249]: wenger : TTY=pts/1 ; PWD=/home/wenger ; USER=root ; COMMAND=/bin/su
3月 07 22:43:44 localhost.localdomain sudo[2249]: pam_unix(sudo:session): session opened for user root by wenger(uid=0)
3月 07 22:43:44 localhost.localdomain su[2250]: (to root) wenger on pts/1
3月 07 22:43:44 localhost.localdomain su[2250]: pam_unix(su:session): session opened for user root by wenger(uid=0)
3月 07 22:43:54 localhost.localdomain polkitd[697]: Registered Authentication Agent for unix-process:2263:11559856 (syst
3月 07 22:43:54 localhost.localdomain 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.
3月 07 22:43:54 localhost.localdomain httpd[2269]: (2)No such file or directory: AH02291: Cannot access directory '/etc/
3月 07 22:43:54 localhost.localdomain httpd[2269]: (2)No such file or directory: AH02291: Cannot access directory '/etc/
3月 07 22:43:54 localhost.localdomain httpd[2269]: AH00014: Configuration check failed
3月 07 22:43:54 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
3月 07 22:43:54 localhost.localdomain 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.
--

注意看No such file or directory: AH02291: Cannot access directory '/etc/,好像是因为找不到什么文件夹。

修复

然后我回忆起了之前删除过缓存目录,查看

1
ls /var/log/

里面确实没有httpd的文件夹。重新创建了httpd的日志文件夹,然后重启服务成功了。

1
2
mkdir /var/log/httpd
systemctl restart httpd