我刚刚安装了 CentOS 7,所以仍在掌握它,但似乎无法弄清楚为什么 Apache 无法在启动时启动。
我已经通过 systemctl 启用了该服务,如果我手动启动它,那么它会正常启动:
[root@CentOS7 pav]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Tue 2015-06-02 14:14:27 BST; 10min ago
Process: 22635 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Main PID: 22641 (httpd)
Status: "Total requests: 1; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
ââ22641 /usr/sbin/httpd -DFOREGROUND
ââ22642 /usr/sbin/httpd -DFOREGROUND
ââ22644 /usr/sbin/httpd -DFOREGROUND
ââ22645 /usr/sbin/httpd -DFOREGROUND
ââ22646 /usr/sbin/httpd -DFOREGROUND
ââ22647 /usr/sbin/httpd -DFOREGROUND
ââ22648 /usr/sbin/httpd -DFOREGROUND
ââ22649 /usr/sbin/httpd -DFOREGROUND
Jun 02 14:14:27 CentOS7 systemd[1]: Started The Apache HTTP Server.
这些是以下错误/var/log/messages
:
Jun 2 09:36:46 CentOS7 httpd: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address 192.168.1.77:80
Jun 2 09:36:46 CentOS7 httpd: no listening sockets available, shutting down
Jun 2 09:36:46 CentOS7 httpd: AH00015: Unable to open logs
Jun 2 09:36:46 CentOS7 systemd: httpd.service: main process exited, code=exited, status=1/FAILURE
答案1
为了清楚起见,从上面的评论中复制...
问题确实是 Apache 试图在网络启动之前启动。运行systemctl enable NetworkManager-wait-online.service
解决了这个问题。
感谢@Bratchley 的帮助。
答案2
在 http.conf 中我们有两行 ip 配置,例如:
Listen 127.0.0.1:80
Listen 80
评论其中之一可能会解决问题。