Centos httpd模組 Job for httpd.service failed because the control process exited with error code.

蔡蔡蔡蔡姬丶發表於2020-11-04

專案場景:

學習Linux的httpd模組報錯:


問題描述:

修改httpd 服務程式的主配置檔案後,重啟httpd服務報了以下錯:

[root@localhost ~]# 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.的報錯資訊
  1. 先是修改80埠號,改為85、95、8088等都無效
  2. (這個沒有操作,因為看不懂)檢視Apache中的 httpd-vhosts.conf 檔案,發現Listen 80 兩次,httpd-vhosts.conf一次,httpd.conf一次,虛擬機器裡的加個#Listen 80
  3. 輸入systemctl status httpd.service 或 journalctl -xe,發現錯誤資訊為
[root@localhost ~]# 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.
  1. 查詢以下錯誤資訊
DocumentRoot '/home/wwwroot' is not a directory, or is not readable

以為是SELinux的原因,關閉SELinux後發現還未成功

  1. 最後發現是第一步修改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(這篇文章最後一句告訴我對症下藥,然後我看了我的報錯資訊)

相關文章