I've been working with Nginx lately and spotted the error Too many open files in the error log. To deal with this I raised the number of files that the Nginx user (www-data) is allowed to open. By default only 1024 files are allowed to be opened. This may be checked by running these commands as user www-data:
ulimit -Hn ulimit -Sn
The H and S refer to hard and soft values and the n switch to number of files. So to raise the limit a bit I added these lines in /etc/security/limits.conf:
www-data hard nofile 16384 www-data soft nofile 16384
The tricky part was to get the system to honour these values. For some reason the ulimit command still showed a value of 1024. The solution was to enable pam_limits in /etc/pam.d/su. I just uncommented the line:
session required pam_limits.so
Changing this value didn't require a restart, I just logged in as www-data again. Running ulimit -a revealed the value 16384.
Comments
Post new comment