Symptoms
This article aims to outline causes and solutions for the "Unable to create lock file: Bad file descriptor" error in the Apache error log which causes 500 internal server errors on PHP websites.
# tail -n0 -f /var/log/apache2/error_log
[:error] [pid 11817] [client 192.0.2.0:52413]
Fatal Error Unable to create lock file: Bad file descriptor (9)
[core:error] [pid 11817] [client 192.0.2.0:52413]
End of script output before headers: index.php
An additional test that can be made to confirm this would be happening; attempting to use the tool "curl" via command line (ssh) to further narrow it down. Here is an example of it here:
# curl -I directtesting.com.au/index.php
HTTP/1.1 503 Service Unavailable
Date: Sat, 20 Feb 2021 02:31:28 GMT
Server: Apache
Connection: close
Content-Type: text/html; charset=iso-8859-1
Description
One cause of this error is the /tmp directory having incorrect permissions:
# stat -c %a /tmp
0755
These permissions will cause Apache to be unable to create session files if /tmp is configured in PHP to store them.
Workaround
If /tmp does not have 1777 permissions, this issue can be corrected with the following command:
chmod -v 1777 /tmp /var/tmp
If you have CageFS enabled and the issue might arise internally in CageFS while active, you may resolve the matter by disabling/renabling the option with the following:
Use the following syntax to manage users:
/usr/sbin/cagefsctl --disable $username [more usernames]
/usr/sbin/cagefsctl --enable $username [more usernames]
Make sure to replace $username with the actual username, you may also use this with multiple username. Or you may invoke these options (--disable all OR --enable all) these details can also be reviewed further in details:
Comments
0 comments
Article is closed for comments.