Apache 未启动;httpd 不工作

Apache 未启动;httpd 不工作

我在 RHEL 7.2 上安装了 apache,下面是我以 root 用户身份启动 apache 时看到的内容:

[root@exampledomain conf]# sudo apachectl start
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@exampledomain conf]# systemctl status httpd.service
● 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 2017-03-06 10:13:04 CST; 13s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 6068 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 6061 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 6061 (code=exited, status=1/FAILURE)

Mar 06 10:13:04 exampledomain.com systemd[1]: Starting The Apache HTTP Server...
Mar 06 10:13:04 exampledomain.com httpd[6061]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address XX.XX.XXX.XX:80
Mar 06 10:13:04 exampledomain.com httpd[6061]: no listening sockets available, shutting down
Mar 06 10:13:04 exampledomain.com httpd[6061]: AH00015: Unable to open logs
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 06 10:13:04 exampledomain.com kill[6068]: kill: cannot find process ""
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 06 10:13:04 exampledomain.com systemd[1]: Failed to start The Apache HTTP Server.
Mar 06 10:13:04 exampledomain.com systemd[1]: Unit httpd.service entered failed state.
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service failed.
[root@exampledomain conf]#

以 root 用户身份运行另一个命令后journalctl -xe,我看到以下内容:

[root@exampledomain conf]# journalctl -xe
Mar 06 10:10:07 exampledomain.com systemd[1]: Stopping user-0.slice.
-- Subject: Unit user-0.slice has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-0.slice has begun shutting down.
Mar 06 10:13:00 exampledomain.com polkitd[15042]: Registered Authentication Agent for unix-process:5884:119511260 (system bus name :1.10361 [/usr/bin
Mar 06 10:13:00 exampledomain.com systemd[1]: Cannot add dependency job for unit microcode.service, ignoring: Unit is not loaded properly: Invalid ar
Mar 06 10:13:00 exampledomain.com 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.
Mar 06 10:13:00 exampledomain.com httpd[5890]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address XX.XX.XXX.XX:80
Mar 06 10:13:00 exampledomain.com httpd[5890]: no listening sockets available, shutting down
Mar 06 10:13:00 exampledomain.com httpd[5890]: AH00015: Unable to open logs
Mar 06 10:13:00 exampledomain.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 06 10:13:00 exampledomain.com kill[5898]: kill: cannot find process ""
Mar 06 10:13:00 exampledomain.com systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 06 10:13:00 exampledomain.com 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.
Mar 06 10:13:00 exampledomain.com systemd[1]: Unit httpd.service entered failed state.
Mar 06 10:13:00 exampledomain.com systemd[1]: httpd.service failed.
Mar 06 10:13:00 exampledomain.com polkitd[15042]: Unregistered Authentication Agent for unix-process:5884:119511260 (system bus name :1.10361, object
Mar 06 10:13:04 exampledomain.com sudo[6052]:   akhare : TTY=pts/1 ; PWD=/etc/httpd/conf ; USER=root ; COMMAND=/sbin/apachectl start
Mar 06 10:13:04 exampledomain.com polkitd[15042]: Registered Authentication Agent for unix-process:6055:119511697 (system bus name :1.10362 [/usr/bin
Mar 06 10:13:04 exampledomain.com systemd[1]: Cannot add dependency job for unit microcode.service, ignoring: Unit is not loaded properly: Invalid ar
Mar 06 10:13:04 exampledomain.com 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.
Mar 06 10:13:04 exampledomain.com httpd[6061]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address XX.XX.XXX.XX:80
Mar 06 10:13:04 exampledomain.com httpd[6061]: no listening sockets available, shutting down
Mar 06 10:13:04 exampledomain.com httpd[6061]: AH00015: Unable to open logs
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 06 10:13:04 exampledomain.com kill[6068]: kill: cannot find process ""
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 06 10:13:04 exampledomain.com 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.
Mar 06 10:13:04 exampledomain.com systemd[1]: Unit httpd.service entered failed state.
Mar 06 10:13:04 exampledomain.com systemd[1]: httpd.service failed.
Mar 06 10:13:05 exampledomain.com polkitd[15042]: Unregistered Authentication Agent for unix-process:6055:119511697 (system bus name :1.10362, object

我看见这个帖子出现同样的错误,并尝试使用那里提到的命令查看端口列表,netstat -punta | grep LISTEN但无法找出问题所在。

命令执行结果netstat -punta如下:

[root@termsprweb1 conf]# netstat -punta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      1350/smbd
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 AAA.AAA.AAA.A:53        0.0.0.0:*               LISTEN      2641/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1718/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1563/cupsd
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      1350/smbd
tcp        0      0 XX.XX.XXX.XX:22         YY.YY.YY.YYY:55863      ESTABLISHED 13706/sshd: myusername
tcp        0     36 XX.XX.XXX.XX:22         YY.YY.YY.YYY:55025      ESTABLISHED 7497/sshd: myusername [
tcp        0      0 XX.XX.XXX.XX:22         YY.YY.YY.YYY:62755      ESTABLISHED 11633/sshd: myusername
tcp        0      0 XX.XX.XXX.XX:22         CC.CC.CC.CCC:54496      ESTABLISHED 9475/sshd: otherusername
tcp        0      0 XX.XX.XXX.XX:22         YY.YY.YY.YYY:55027      ESTABLISHED 7499/sshd: myusername [
tcp        0      0 XX.XX.XXX.XX:22         YY.YY.YY.YYY:62723      ESTABLISHED 11423/sshd: myusername
tcp6       0      0 :::3306                 :::*                    LISTEN      1799/mysqld
tcp6       0      0 :::139                  :::*                    LISTEN      1350/smbd
tcp6       0      0 :::111                  :::*                    LISTEN      1916/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      1718/sshd
tcp6       0      0 :::445                  :::*                    LISTEN      1350/smbd
udp        0      0 AAA.AAA.AAA.A:53        0.0.0.0:*                           14932/dnsmasq
udp        0      0 AAA.AAA.AAA.A:53        0.0.0.0:*                           2641/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           14932/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           2641/dnsmasq
udp        0      0 0.0.0.0:111             0.0.0.0:*                           1916/rpcbind
udp        0      0 XX.XX.XXX.XX:123        0.0.0.0:*                           2968/ntpd
udp        0      0 AAA.AAA.AAA.A:123       0.0.0.0:*                           2968/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           2968/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           2968/ntpd
udp        0      0 0.0.0.0:43237           0.0.0.0:*                           1672/avahi-daemon:
udp        0      0 0.0.0.0:819             0.0.0.0:*                           1916/rpcbind
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           1672/avahi-daemon:
udp6       0      0 :::111                  :::*                                1916/rpcbind
udp6       0      0 :::123                  :::*                                2968/ntpd
udp6       0      0 :::819                  :::*                                1916/rpcbind


where  YY.YY.YY.YYY  is my system IP address.

       XX.XX.XXX.XX  is the server on which Apache is installed

答案1

跑步

 journalctl -u httpd.service

并找到确切的错误。如果响应类似 在此处输入图片描述

发生这种情况是因为

httpd(pid 5228)已运行

因此终止该进程。(使用上述命令查找 pid)

 kill 9 5228

然后启动httpd服务。

service httpd start

相关内容