端口 80 上的进程阻止 apache2 服务

端口 80 上的进程阻止 apache2 服务

我的apache2出现以下错误:

root@Aspire3:/etc/apache2# systemctl status apache2
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Thu 2020-10-08 20:42:23 -03; 4min 48s ago
  Process: 24443 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

out 08 20:42:23 Aspire3 apachectl[24443]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this
out 08 20:42:23 Aspire3 apachectl[24443]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
out 08 20:42:23 Aspire3 apachectl[24443]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
out 08 20:42:23 Aspire3 apachectl[24443]: no listening sockets available, shutting down
out 08 20:42:23 Aspire3 apachectl[24443]: AH00015: Unable to open logs
out 08 20:42:23 Aspire3 apachectl[24443]: Action 'start' failed.
out 08 20:42:23 Aspire3 apachectl[24443]: The Apache error log may have more information.
out 08 20:42:23 Aspire3 systemd[1]: apache2.service: Control process exited, code=exited status=1
out 08 20:42:23 Aspire3 systemd[1]: apache2.service: Failed with result 'exit-code'.
out 08 20:42:23 Aspire3 systemd[1]: Failed to start The Apache HTTP Server.

然后我发现响应并且成功了!但是每当我重新启动计算机时,A​​pache 都会返回此错误,我必须再次运行这些命令。有人知道如何解决吗?我使用 Ububtu 18.04

答案1

可能是你的防火墙存在问题。

尝试一下sudo ufw allow 'Apache Full'; sudo systemctl restart apache2,看看是否有帮助。

如果没有,请提供更多有关您需要运行的命令的详细信息,以便让服务器重新运行。最坏的情况是,您可以用这些命令制作一个 bash 脚本,然后创建一个 cron 作业以在启动时运行它们(这不是最好的解决方案,但它有效)。

答案2

我现在有这个问题。我弄清楚了问题所在,我安装了 NextCloud,它产生了 4 个不同的 httpd 进程在端口 80 上监听。我是这样解决这个问题的,第一次运行:

sudo ss -6 -tlnp | grep 80

并输出:

LISTEN    0         511                      *:80                     *:*        users:(("httpd",pid=3736,fd=4),("httpd",pid=3735,fd=4),("httpd",pid=3734,fd=4),("httpd",pid=3732,fd=4))

我尝试终止所有这些进程,但它立即产生了新的进程:

LISTEN    0         511                      *:80                     *:*        users:(("httpd",pid=220235,fd=4),("httpd",pid=220234,fd=4),("httpd",pid=220233,fd=4),("httpd",pid=220232,fd=4))

为了找出是什么产生了这些进程,我运行了这个:

ps -feww | grep httpd

输出:

root      219647       1  0 16:00 ?        00:00:00 /bin/sh /snap/nextcloud/28403/bin/run-httpd -k start -DFOREGROUND
root      220190  219647  0 16:00 ?        00:00:00 /bin/sh /snap/nextcloud/28403/bin/httpd-wrapper -k start -DFOREGROUND
root      220232  220190  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220233  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220234  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220235  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
sugarca+  230559   19376  0 16:02 pts/0    00:00:00 grep --color=auto httpd

因此,为了解决这个问题,我卸载了 nextcloud。

相关内容