Apache shutdown - Couldn't grab mutex

醉酒当歌 提交于 2019-12-04 09:02:43

I was experiencing the same error on Ubuntu 17.10 with Apache 2.4.27.

It appears to have to do with Apache talking to the OS about file locking. When I went into /etc/apache2/apache2.conf and added Mutex flock to the Mutex section (near the ServerRoot section), it seems to have solved the problem.

Unfortunately, all I can say is that this uses the flock() function (a system call?) to handle file locking. Per https://httpd.apache.org/docs/2.4/mod/core.html#mutex

So it's a bit of a black magic fix in that I personally am not familiar enough with Apache's file locking behavior to say why it works, and I can only say it works because the Apache crash seems to have stopped, but only thus far. Nevertheless, it may help you and seems fairly low-risk.

You haven't shared the complete log trace. It could be:

[Sun Jul 21 15:49:43 2019] [error] (12)Cannot allocate memory: fork: Unable to fork new process

This is due to low memory and apache failed to create new processes. It also depends on the number of processes you have configured it to fork. It happens when there is too much traffic on to the website.

While Sean solution is valid, I learned another way to solve this problem.

First, you should know that this problem is related to using Certbot and SSL certificates on Ubuntu.

Now, to solve the problem without doing anything you're unsure of, simply do this (as root or with sudo):

  1. Create the following file: /etc/apache2/conf-available/mutex-file.conf
  2. Add Mutex file:${APACHE_LOCK_DIR} default inside the newly created file
  3. Enable new configuration file with a2enconf mutex-file.conf
  4. Restart Apache with systemctl restart apache2

But hey, it's already enabled by default! Why make a file just for that?

I though the same when I found this solution.

By one wonder or another, it seems that once your start using SSL certificates, this configuration line is somehow "ignored".
Thus, Apache fail to find the lock dir for the mutex file.

Just adding (remove comment) this line into /etc/apache2/apache2.conf isn't working either.
You have to specifically create a configuration file and enable it.
Else it won't solve the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!