项目场景:
学习Linux的httpd模块报错:
问题描述:
修改httpd 服务程序的主配置文件后,重启httpd服务报了以下错:
[[email protected] ~]# systemctl restart httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
原因分析:
其实最开是就应该想到是配置文件写错了,因为是修改文件后报错的。。。但还是记录一下一步一步的解决问题思路吧。
解决步骤:
搜索Job for httpd.service failed because the control process exited with error code.的报错信息
- 先是修改80端口号,改为85、95、8088等都无效
- (这个没有操作,因为看不懂)查看Apache中的 httpd-vhosts.conf 文件,发现Listen 80 两次,httpd-vhosts.conf一次,httpd.conf一次,虚拟机里的加个#Listen 80
- 输入systemctl status httpd.service 或 journalctl -xe,发现错误信息为
[[email protected] ~]# 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: exit-code) since Wed 2020-11-04 23:46:48 CST; 10s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3319 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 3609 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 3609 (code=exited, status=1/FAILURE)
Nov 04 23:46:48 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Nov 04 23:46:48 localhost.localdomain httpd[3609]: AH00526: Syntax error on line 119 of /etc/httpd/conf/httpd.conf:
Nov 04 23:46:48 localhost.localdomain httpd[3609]: DocumentRoot '/home/wwwroot' is not a directory, or is not readable
Nov 04 23:46:48 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Nov 04 23:46:48 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
Nov 04 23:46:48 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Nov 04 23:46:48 localhost.localdomain systemd[1]: httpd.service failed.
- 查询以下错误信息
DocumentRoot '/home/wwwroot' is not a directory, or is not readable
以为是SELinux的原因,关闭SELinux后发现还未成功
- 最后发现是第一步修改httpd的配置文件中Directory目录写错(写多了一个o),conf错误内容如下
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/wwworoot"
#
# Relax access to content within /var/www.
#
<Directory "/home/wwwrooot">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/home/wwwrooot">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
修改Directory目录后正确生效
参考:
https://blog.csdn.net/weixin_30709635/article/details/99143232
https://blog.csdn.net/wangxiaoming099/article/details/23165575
https://blog.csdn.net/zhuoyr/article/details/8393854
https://tpyyes.com/a/linux/616.html(这篇文章最后一句告诉我对症下药,然后我看了我的报错信息)