![CentOS 7:httpd.service 作业失败](https://linux22.com/image/131197/CentOS%207%EF%BC%9Ahttpd.service%20%E4%BD%9C%E4%B8%9A%E5%A4%B1%E8%B4%A5.png)
我有一个 CentOS 7 VPS,我正在尝试按照以下说明安装虚拟主机https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7。
我已完成本教程的第五步。然后,当我尝试重新启动 apache 时,我失败了:
$ sudo apachectl restart
[sudo] password for student01:
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
$ sudo systemctl status httpd.service -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since বুধ 2018-04-11 14:29:55 +06; 4min 13s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 11116 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 11115 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 11115 (code=exited, status=1/FAILURE)
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
এপ্রি 11 14:29:55 localhost.localdomain kill[11116]: kill: cannot find process ""
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
এপ্রি 11 14:29:55 localhost.localdomain systemd[1]: httpd.service failed.
现在,我能做什么?
编辑
/var/log/httpd/error_log
[Sun Apr 08 03:23:02.040472 2018] [auth_digest:notice] [pid 20339] AH01757: generating secret for digest authentication ...
[Sun Apr 08 03:23:02.041376 2018] [lbmethod_heartbeat:notice] [pid 20339] AH02282: No slotmem from mod_heartmonitor
[Sun Apr 08 03:23:02.094944 2018] [mpm_prefork:notice] [pid 20339] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Sun Apr 08 03:23:02.094956 2018] [core:notice] [pid 20339] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Apr 08 05:35:00.720095 2018] [autoindex:error] [pid 30351] [client 66.102.6.114:59512] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Sun Apr 08 09:42:05.222459 2018] [autoindex:error] [pid 30347] [client 52.34.24.33:31614] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Sun Apr 08 11:06:56.497939 2018] [autoindex:error] [pid 30790] [client 54.145.188.132:22136] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Sun Apr 08 14:13:12.731870 2018] [autoindex:error] [pid 32239] [client 185.198.167.29:51750] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Sun Apr 08 19:06:12.521882 2018] [autoindex:error] [pid 30348] [client 180.234.211.210:57961] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Sun Apr 08 19:06:15.004820 2018] [autoindex:error] [pid 30790] [client 159.203.81.93:36934] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive, referer: http://csedu.cf/noindex/css/open-sans.css
[Sun Apr 08 21:20:59.825782 2018] [autoindex:error] [pid 1338] [client 66.102.6.114:52716] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 00:25:17.935192 2018] [autoindex:error] [pid 30348] [client 178.73.215.171:58579] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 02:50:04.593613 2018] [autoindex:error] [pid 30351] [client 141.8.142.139:50790] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 03:17:12.517868 2018] [autoindex:error] [pid 30347] [client 222.186.173.47:3128] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 04:10:37.253275 2018] [autoindex:error] [pid 31639] [client 164.132.91.1:38580] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 05:38:34.833406 2018] [autoindex:error] [pid 30350] [client 66.249.70.23:49821] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 05:42:25.297309 2018] [autoindex:error] [pid 30790] [client 66.102.6.118:49432] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 08:37:04.505363 2018] [autoindex:error] [pid 1338] [client 66.249.64.17:47360] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 11:34:29.890432 2018] [autoindex:error] [pid 30349] [client 60.10.114.129:4892] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 12:21:16.013396 2018] [autoindex:error] [pid 30351] [client 66.249.64.147:61628] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 13:16:44.877416 2018] [autoindex:error] [pid 30348] [client 66.249.64.18:48720] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 13:28:05.782783 2018] [autoindex:error] [pid 31639] [client 54.67.59.131:47628] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 15:59:59.764704 2018] [autoindex:error] [pid 30349] [client 66.102.6.116:50307] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 20:48:48.419540 2018] [autoindex:error] [pid 30349] [client 211.23.154.138:44382] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 20:49:19.596952 2018] [autoindex:error] [pid 30790] [client 146.185.223.240:61291] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 20:49:25.365282 2018] [:error] [pid 32239] [client 146.185.223.240:53694] script '/var/www/html/xmlrpc.php' not found or unable to stat
[Mon Apr 09 20:49:30.881307 2018] [autoindex:error] [pid 1338] [client 146.185.223.240:57697] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 21:59:59.860423 2018] [autoindex:error] [pid 30790] [client 52.41.211.72:54578] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 22:40:17.025377 2018] [autoindex:error] [pid 32239] [client 66.102.6.118:63371] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 09 23:54:26.754931 2018] [autoindex:error] [pid 30350] [client 141.8.142.139:44732] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 02:04:12.364159 2018] [autoindex:error] [pid 30350] [client 66.249.64.17:46304] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 04:31:13.380666 2018] [autoindex:error] [pid 30349] [client 66.249.79.21:45988] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 05:11:35.587141 2018] [autoindex:error] [pid 32239] [client 66.249.79.19:52379] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 05:41:26.176137 2018] [autoindex:error] [pid 1338] [client 66.102.6.118:51864] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 05:57:36.520454 2018] [autoindex:error] [pid 30347] [client 66.249.79.110:36194] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 12:44:25.251573 2018] [autoindex:error] [pid 32239] [client 52.34.24.33:60587] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 13:08:39.896323 2018] [autoindex:error] [pid 1338] [client 141.8.142.139:53710] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 13:31:14.603115 2018] [autoindex:error] [pid 30790] [client 180.234.211.210:44472] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 13:42:16.181640 2018] [autoindex:error] [pid 30351] [client 107.170.192.57:54176] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 16:31:20.752769 2018] [autoindex:error] [pid 30349] [client 196.52.43.109:6666] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 17:43:24.572519 2018] [autoindex:error] [pid 1338] [client 66.102.6.118:64283] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Tue Apr 10 23:32:45.653283 2018] [mpm_prefork:notice] [pid 20339] AH00170: caught SIGWINCH, shutting down gracefully
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
答案1
第一条消息httpd.service: main process exited, code=exited, status=1/FAILURE
表明该服务甚至无法启动。下一条消息kill[11116]: kill: cannot find process ""
想说的是,服务进程无法被杀死,因为它之前无法启动。
/var/log/httpd/error_log
根据来自服务因虚拟主机定义问题而停止的日志消息
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/example2.com/error.log.
AH00015: Unable to open logs
如果服务无法写入配置的日志文件,因为
- 该目录不存在
- 硬盘是只读的
- 硬盘已满
服务无法启动。
我们还必须查看 VirtualHost 配置example2.com
。
我怀疑您的服务配置发生了一些问题,因为一方面日志说 DocumentRoot 位于/var/www/html/
但它想要将日志写入/var/www/example2.com/
答案2
尝试注释 /etc/httpd/conf/httpd.conf 中的行:
#LoadModule mpm_event_module modules/mod_mpm_event.so
并取消注释该行:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so