Obtain the following error log in my nginx configuration file:
2010/04/16 13:24:16 [crit] 21974 #0: * 3188937 open ()"/Usr/local/nginx/html/50x.html "failed (24: Too program open files), Client: 88. x. y. z, server: example.com, request: "GET/file/images/background.jpg HTTP/1.1", upstream: "http: // 10.8.4.227: 81 // file/images/background.jpg ", host: "example.com"
How can I fix problems such as CentOS/RHEL/Fedora Linux or UNIX?
Linux/Unix sets the hardware and software file handle and the number of opened files. You can use the 'ulimit 'command to view these restrictions.
Su-nginx
To view these values, run the following command:
Ulimit-Hn
Ulimit-Sn
Increase the limit on file opening at the Linux system level
The number of files that can be opened on the nginx server is limited by your operating system. You can easily fix this problem by setting or increasing system open file limits. Edit the/etc/sysctl. conf file and type:
Vi/etc/sysctl. conf
Append or modify the following rows:
Fs. file-max = 70000
Save and close the file, edit/etc/security/limits. conf, and type:
Vi/etc/security/limits. conf
Set the hardware and software limits for all users or nginx users as follows:
Nginx soft nofile 10000
Nginx hard nofile 30000
Save and close, and load the sysctl command again to make the preceding changes take effect:
Sysctl-p
Nginx worker_rlimit_nofile Option (to improve the restrictions on opened file handles at the nginx level)
Nginx has the same restrictions. You can use worker_rlimit_nofile to increase the limit. To set the maximum number of files opened by the nginx process, edit the nginx. conf file, and type:
Vi/usr/local/nginx/conf/nginx. conf (depending on the location of your configuration file)
Append or edit:
Worker_rlimit_nofile 30000;
Save and close the file, reload the nginx configuration, and re-execute the command to view the hardware and software restrictions:
Su-nginx
Ulimit-Hn
Ulimit-Sn
Input example:
30000
10000
In fact, most of the content found on Chinese websites is about to be mentioned. I used to do the same, but it has not been resolved. Finally, I found that the most critical parameters were not set, therefore, the number of active conntions cannot exceed 1024. you can solve this problem by setting this parameter:
Worker_rlimit_nofile 30000;
Translate from: http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/