Apache关闭-无法获取互斥锁

Pre*_*iel 5 ubuntu apache2 apache2.4 ubuntu-18.04

由于某些原因,我不知道Apache崩溃了。

这是崩溃时的apache日志:

[Sat Jun 02 02:38:05.196006 2018] [mpm_prefork:emerg] [pid 1122] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:05.196006 2018] [mpm_prefork:emerg] [pid 1116] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:05.198767 2018] [mpm_prefork:emerg] [pid 1115] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:05.199523 2018] [mpm_prefork:emerg] [pid 3924] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:05.204189 2018] [mpm_prefork:emerg] [pid 1937] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:05.207362 2018] [mpm_prefork:emerg] [pid 1120] (43)Identifier removed: AH00144: couldn't grab the accept mutex
[Sat Jun 02 02:38:06.057310 2018] [core:alert] [pid 1099] AH00050: Child 1115 returned a Fatal error... Apache is exiting!
[Sat Jun 02 02:38:06.057483 2018] [:emerg] [pid 1099] AH02818: MPM run failed, exiting
Run Code Online (Sandbox Code Playgroud)

我最近在服务器上所做的最后一件事是将certbot安装到我站点的常规HTTPS证书中。

Pre*_*iel 19

虽然肖恩的解决方案是有效的,但我学到了另一种解决这个问题的方法。

首先,您应该知道这个问题与在 Ubuntu 上使用 Certbot 和 SSL 证书有关。

现在,要在不做任何您不确定的事情的情况下解决问题,只需执行以下操作(以 root 身份或使用 sudo):

  1. 创建以下文件: /etc/apache2/conf-available/mutex-file.conf
  2. Mutex file:${APACHE_LOCK_DIR} default在新创建的文件中添加
  3. 启用新的配置文件 a2enconf mutex-file
  4. 重新启动Apache systemctl restart apache2

但是,嘿,它已经默认启用了!为什么要为此创建一个文件?

当我找到这个解决方案时,我也一样。

奇怪的是,似乎一旦您开始使用 SSL 证书,这条配置行就会以某种方式被“忽略”。
因此,Apache 无法找到互斥锁文件的锁目录。

只是添加(删除评论)这一行/etc/apache2/apache2.conf也不起作用。
您必须专门创建一个配置文件并启用它。
否则解决不了问题。


Sea*_*gge 6

我在使用Apache 2.4.27的Ubuntu 17.10上遇到了相同的错误。

这似乎与Apache与OS讨论文件锁定有关。当我进入/etc/apache2/apache2.conf并添加Mutex flock到Mutex部分(在ServerRoot部分附近)时,似乎已经解决了该问题。

不幸的是,我只能说这使用flock()函数(系统调用?)来处理文件锁定。根据https://httpd.apache.org/docs/2.4/mod/core.html#mutex

因此,这有点像个不可思议的修正,因为我个人对Apache的文件锁定行为还不够熟悉,无法说明它为什么起作用,而我只能说它起作用,因为Apache崩溃似乎已经停止了,但是到目前为止。但是,它可能会对您有所帮助,而且风险似乎较低。


Mun*_*raj 5

在我的情况下,以下步骤对我有用。

  1. 通过 SSH 连接到服务器

  2. 编辑 /etc/apache2/apache2.conf 文件。下面的命令我使用了 nano 编辑器,你可以使用你最喜欢的编辑器

须藤纳米 /etc/apache2/apache2.conf

  1. 搜索“互斥锁”部分

  2. 添加以下行,

互斥锁

  1. 保存并关闭文件。

  2. 通过运行命令在重新启动 Apache 服务之前检查配置,

须藤 apachectl configtest

  1. 如果以上检查一切正常,则重新启动 Apache 服务,

须藤服务 apache2 重启

希望这可以帮助某人。