Rhel

無法在 RHEL 7 上啟動 httpd

  • January 29, 2020

我無法在 RHEL 7 上啟動 httpd。

[root@machine]# systemctl restart httpd
Failed to restart httpd.service: Unit not found.

我試過…

yum update -y
yum install httpd -y
systemctl restart httpd

結果相同。Apache 配置看起來不錯:

[root@machine]# httpd -t
Syntax OK

Red Hat Enterprise Linux Server 7.7 版 (Maipo)


[root@machine me]# rpm -q httpd
httpd-2.4.6-90.el7.x86_64

[root@machine me]# systemctl status httpd
● httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since Mon 2020-01-27 15:38:54 CST; 1 day 16h ago
    Docs: man:httpd(8)
          man:apachectl(8)
 Process: 36851 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
 Process: 36849 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 36849 (code=exited, status=1/FAILURE)

Jan 27 15:38:54 faspbsy0002 httpd[36849]: (98)Address already in use: AH0007...0
Jan 27 15:38:54 faspbsy0002 httpd[36849]: (98)Address already in use: AH0007...0
Jan 27 15:38:54 faspbsy0002 httpd[36849]: no listening sockets available, sh...n
Jan 27 15:38:54 faspbsy0002 httpd[36849]: AH00015: Unable to open logs
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service: main process exited, ...E
Jan 27 15:38:54 faspbsy0002 kill[36851]: kill: cannot find process ""
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service: control process exite...1
Jan 27 15:38:54 faspbsy0002 systemd[1]: Failed to start The Apache HTTP Server.
Jan 27 15:38:54 faspbsy0002 systemd[1]: Unit httpd.service entered failed state.
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

問題似乎是我安裝了兩個不同版本的 Apache:標準版本和 Red Hat Software Collections 中的一個。

[root@faspbsy0002 httpd24]# yum list installed | grep httpd
httpd.x86_64                  2.4.6-90.el7             @rhel-7-server-rpms      
httpd-tools.x86_64            2.4.6-90.el7             @rhel-7-server-rpms      
httpd24-httpd.x86_64          2.4.34-7.el7.1           @rhel-server-rhscl-7-rpms
httpd24-httpd-tools.x86_64    2.4.34-7.el7.1           @rhel-server-rhscl-7-rpms
httpd24-libcurl.x86_64        7.61.1-2.el7             @rhel-server-rhscl-7-rpms
httpd24-libnghttp2.x86_64     1.7.1-7.el7              @rhel-server-rhscl-7-rpms
httpd24-mod_ssl.x86_64        1:2.4.34-7.el7.1         @rhel-server-rhscl-7-rpms
httpd24-runtime.x86_64        1.1-18.el7               @rhel-server-rhscl-7-rpms

要重新啟動 Apache,我需要做…

systemctl restart httpd24-httpd

而且我可能還應該刪除我不使用的 Apache 版本。

我還發現httpd -V在這種情況下具有誤導性,因為它提供了標準 Apache 的 httpd_root 和 document_root,但那不是正在使用的 Apache。

在我看來,未找到單位似乎httpd沒有得到適當的服務。

嘗試以下

systemctl is-enabled httpd
systemctl is-active httpd

如果兩者都再次返回unit not found,請嘗試httpd再次安裝,首先備份您的配置。

yum remove httpd

yum search apache
yum install httpd

引用自:https://unix.stackexchange.com/questions/564452