This article gives you a lot of reasons for the cause of the 500 Internal Server Error error in nginx. Summary and solution analysis Need to know friends can refer to the reference
Now more and more sites are starting With Nginx, ("engine x") is a high-performance HTTP and reverse proxy server and an IMAP/POP3/SMTP proxy server. Nginx was developed by Igor Sysoev for the second-most visited Rambler.ru site in Russia, which has been running on the site for more than two and a half years. Igor publishes the source code as a class BSD license. In the case of high concurrent connections, Nginx is a good alternative to the Apache server. Nginx can also be used as a 7-layer load balancing server. According to the test results, Nginx 0.6.31 + PHP 5.2.6 (FastCGI) can withstand more than 30,000 concurrent connections, which is equivalent to 10 times that of Apache in the same environment. However, many people will get 500 errors when using Nginx. According to my usage, a large part of the reason is because the file open handle is too small.
Under linux Use this command to increase the file handle opened by the process. Ulimit -SHn 51200 The default is only 1000. When the number of links is small, you can't see it. This method can effectively prevent 500 errors from occurring. When I visit the website today, I occasionally encounter the error message page of 500 Internal Server Error. I checked the relevant information and found that the access is too large, and the system kernel process is limited.
The answer is as follows:
$ ulimit -n 11095
The program limit can only open 11095 files. The ulimit command is to set the number of file descriptors that a current user can have. It seems that there are too many concurrent concurrency. Need to adjust the number of concurrent settings of nginx.conf, (My configuration host memory 2G, CPU is 2.8G,)
vi /etc/nginx/nginx.conf events { worker_connections 1024; }
Adjust to
events { worker_connections 10240; }
The above problem will still occur, using [root@qimutian nginx]# cat /proc/sys/fs/file-max 8192 The maximum number of open files in the file system [root@qimutian nginx]# ulimit -n 1024 Program limit can only open 1024 files Use [root@qimutian nginx]# ulimit -n 8192 to adjust or permanently adjust the number of open files in the startup file Add at the end of /etc/rc.d/rc.local (in /etc/sysctl.conf Add fs.file-max=8192) ulimit -n 8192 Adjust the number of CentOS5 file openes Use ulimit -a to find that OPEN FILES can't exceed 1024 by default. Yesterday's stress test showed 500 errors. Please check nginx for details. 500 Internal Server Error Look up in the morning and find that it was adjusted as follows. Method 1 (permanent adjustment)
vi /etc/security/limits.conf
Add at the end of the file: Br>
* soft nofile 8192 * hard nofile 20480
At the same time vi /etc/sysctl.conf add fs.file-max=8192 to restart, the number used in ulimit -n is already 8192
Method 2 (temporary)
Enter ulimit -n 8192 directly in the terminal. Press Enter to ok.
500 Internal Server Error error added: 1. Hard disk space is full
Use df -k to see if the hard disk space is full. Clearing the hard disk space will solve the 500 error. If nginx has access log enabled, it is best to close the access log if it is not needed. The access log takes up a lot of hard disk space. 2, nginx configuration file error
This is not a syntax error, nginx if the configuration file has a syntax error, it will prompt when starting. When rewrite is configured, some rules will be mishandled with 500 errors. Please check your rewrite rules carefully. If some variables in the configuration file are not set properly, there will be a 500 error, such as referencing a variable with no value. 3. If none of the above problems exist, there may be too many concurrent concurrency. You need to adjust the number of concurrent settings of nginx.conf.
The solution is:
1 Open /etc/Security/limits.conf file, plus two sentences
* soft nofile 65535 * hard nofile 65535
2 Open /etc/nginx/nginx.conf Add a line below worker_processes
worker_rlimit_nofile 65535;
3 Restart nginx, reload settings
kill -9 `ps -ef
server perfect settings, support asp php cgi jsp asp.net mysql! First download the program we want
At present, there are more and more schools using Windows 2003 as a web server. However, for users w
Problem Description The R525 G2 machine serial port interface is in the form
When using OpenFlashChart control to display charts in .NET, who would have thought that the display
Win2003 allows SHTML files by default?
Some heat of summer on room mine awareness
Preventing database files from being downloaded by safely configuring IIS
Knowledge Academy: Two major points to be aware of server hosting
Windows server system log: system startup time is seconds | Eventlog 6013
The server only left the C disk administrator authority, the problem was
Is the blade server really not suitable for SMEs?
RAID is mature. Disk Redundancy Array Technology Resolution
How much has the status quo and future of virtualization technology changed?
Skills: How to improve data center cabling?
Troubleshoot that the SSH server cannot log in
Intel's six-core and eight-core server CPU architecture analysis
QQ for win10 installation tips How to install qq for win10
Dolphin simulator setup tutorial
Win8.1 uses IE11 to create a flower screen solution coup
Under the Win7 ultraEdit, etc. correctly display Japanese, Korean and other fonts
Shut down or hibernate? A command tells you the last way Win10 was closed
7-inch Win10 tablet phone Holofone comes out: comes with a projector
Windows 8 Consumer Preview Edition Micro-Experience
360 suspend Win10 upgrade notification
Win10 upgrade failure prompts to find the boot.wim installation file solution
Vista did not find the "hibernate" option. What are the reasons?