由于某种原因,我的 apache2 停止工作了。我尝试卸载它,但问题仍然存在。以下是我尝试过的一些命令及其结果,希望对您有所帮助:
sudo systemctl status apache2
:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2020-06-21 13:41:56 IST; 13min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 19571 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
Jun 21 13:41:56 kabir systemd[1]: apache2.service: Control process exited, code=exited status=1
Jun 21 13:41:56 kabir systemd[1]: apache2.service: Failed with result 'exit-code'.
Jun 21 13:41:56 kabir systemd[1]: Failed to start The Apache HTTP Server.
Jun 21 13:41:56 kabir apachectl[19571]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1
Jun 21 13:41:56 kabir apachectl[19571]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Jun 21 13:41:56 kabir apachectl[19571]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Jun 21 13:41:56 kabir apachectl[19571]: no listening sockets available, shutting down
Jun 21 13:41:56 kabir apachectl[19571]: AH00015: Unable to open logs
Jun 21 13:41:56 kabir apachectl[19571]: Action 'start' failed.
Jun 21 13:41:56 kabir apachectl[19571]: The Apache error log may have more information.
sudo systemctl restart apache2
:
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
netstat -an | grep ":80"
:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 192.168.43.128:33944 117.18.237.29:80 TIME_WAIT
tcp 0 0 192.168.43.128:33864 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34524 23.217.53.84:80 ESTABLISHED
tcp 0 0 192.168.43.128:54364 172.217.166.163:80 ESTABLISHED
tcp 0 0 192.168.43.128:54206 172.217.166.163:80 TIME_WAIT
tcp 0 0 192.168.43.128:33946 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34522 23.217.53.84:80 ESTABLISHED
tcp6 0 0 :::80 :::* LISTEN
sudo apachectl start
:
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Action 'start' failed.
The Apache error log may have more information.
sudo netstat -lnap
:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
-
tcp6 0 0 :::80 :::* LISTEN 1276/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1276/nginx: master
答案1
你不能让两个 HTTP 服务器在同一台机器上监听同一个端口(除非你把它们放在不同的接口上,或者你使用桥接网络连接)看起来nginx服务器正在您的系统中运行,因此如果您想使用 Apache2,您可以停止nginx服务 :
sudo service nginx stop
如果你想阻止nginx在启动时自动启动(这可能会阻止 apache2 启动,反之亦然),你可以通过以下方式禁用其服务系统控制:
sudo systemctl disable nginx