PHP-fpm Too Many Open Files 24 Error (set open file descriptor limit)

www.l‮iruttua‬.com
PHP-fpm Too Many Open Files 24 Error (set open file descriptor limit)

If you are seeing an error message similar to "PHP-fpm: Too many open files (24)" when running PHP-fpm, it means that the maximum number of open file descriptors allowed by the system has been reached. This can occur when a PHP script or application tries to open too many files at once, or when a script or application has a file descriptor leak that causes the number of open file descriptors to grow over time.

To fix this issue, you will need to increase the maximum number of open file descriptors allowed by the system. This can usually be done by modifying the ulimit setting for the user account running PHP-fpm.

To do this, you can use the following steps:

  1. Find the user account that PHP-fpm is running under. This can usually be done by checking the user setting in the PHP-fpm configuration file (usually php-fpm.conf).

  2. Edit the /etc/security/limits.conf file and add a line for the user account with the following format:

username hard nofile 65535

Replace username with the actual name of the user account. The nofile setting specifies the maximum number of open file descriptors allowed for the user. In this example, the maximum number of open file descriptors is set to 65535.

  1. Save the changes to the limits.conf file and log out and log back in for the changes to take effect.

  2. Check the current ulimit setting for the user account using the following command:

ulimit -n

This should return the maximum number of open file descriptors allowed for the user. If the value returned is less than the value you specified in the limits.conf file, you may need to add the following line to the /etc/pam.d/common-session file:

session required pam_limits.so

This will ensure that the ulimit setting is applied when the user logs in.

  1. Restart PHP-fpm to apply the changes.

It's important to note that increasing the maximum number of open file descriptors allowed by the system may have performance implications, particularly on systems with limited resources. It is also recommended to optimize your PHP scripts and applications to minimize the number of files that they need to open concurrently.

Created Time:2017-10-30 14:27:09  Author:lautturi