In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what to do when there are 500 Internal Server Error errors in Nginx. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
500 (server internal error) the server encountered an error and was unable to complete the request.
The 501 (not yet implemented) server does not have the ability to complete the request. For example, the server might return this code when the server does not recognize the request method.
The 502 (error gateway) server, as a gateway or proxy, received an invalid response from the upstream server.
503 (service unavailable) the server is currently unavailable (due to overloading or downtime maintenance). Usually, this is just a temporary state.
504 (Gateway timeout) the server, as a gateway or proxy, did not receive requests from the upstream server in time.
505 (HTTP version is not supported) the server does not support the HTTP protocol version used in the request.
Nginx 500error (Internal Server Error internal server error): 500error refers to an internal error on the server, that is, the server encounters an unexpected condition and is unable to fulfill the request.
In the case of high concurrent connections, Nginx is a good alternative to Apache servers. Nginx can also be used as a 7-tier 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 10 times that of Apache in the same environment.
But a lot of people will make 500 errors when using Nginx. According to the situation I use, there are several situations.
1. Is there insufficient disk space?
Use df-k to see if the hard drive is full. 500 errors can be solved by cleaning up hard disk space. Nginx if access log is enabled, it is best to turn off access log if it is not needed. Access log takes up a lot of hard disk space.
2. Nginx configuration file error?
This does not mean syntax errors. Nginx will prompt when it starts if there is a syntax error in the configuration file. When configuring rewrite, some rules will cause 500 errors if they are not handled properly. Please check your rewrite rules carefully. If some variables in the configuration file are not set properly, there will also be a 500 error, such as referencing a variable with no value.
3. If none of the above problems exist, it may be that the number of concurrency in the simulation is too large, so you need to adjust the number of concurrency settings in nginx.conf.
4. There is also the failure caused by the full use of Linux index nodes (inode), df-I
500 problem caused by full index node (inode) https://www.jb51.net/article/175430.htm
Inode is translated into Chinese as an index node. After each storage device (such as a hard disk) or partition of a storage device is formatted into a file system, there should be two parts, one is inode, the other is Block,Block is used to store data. Inode, on the other hand, is the information used to store these data, including file size, ownership, user group, read and write permissions, and so on. Inode indexes the information for each file, so you have the value of inode. According to the instructions, the operating system can find the corresponding file with the fastest value of inode. Although the server's Block is still left, the inode is full, so when creating a new directory or file, the system prompts you that there is not enough disk space.
General analysis ideas:
(1) View nginx error log and php error log
Nginx error log error.log default location: / usr/local/nginx/logs
(2) if too many open files, modify the worker_rlimit_nofile parameter of nginx, use ulimit to view the file opening limit of the system, and modify / etc/security/limits.conf
(3) if it is a script problem, you need to fix the script error and optimize the code.
(4) if all kinds of optimizations are done well, if too many open files still appears, you should consider doing load balancing and distributing the traffic to different servers.
The solution is:
1 Open the / etc/security/limits.conf file and add two sentences
The code is as follows:
* soft nofile 65535 * hard nofile 65535
2 Open / etc/nginx/nginx.conf
Add a line under worker_processes
The code is as follows:
Worker_rlimit_nofile 65535
3 restart nginx and reload settings
The code is as follows:
Kill-9 `ps-ef | grep php | grep-v grep | awk'{print $2}'`/ usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-C 100-u www-data-f / usr/bin/php-cgikillall-HUP nginx
After rebooting, look at the error log of nginx, and there are no errors reported.
4. There may be a database problem. My nginx log php log did not find any problems. Finally, I found that the database could not be accessed and the problem was solved after correction.
If the above method still does not solve the problem, it may be a configuration or program error.
1 check the error log of nginx to find the possible cause.
If you are prompted that some PHP extensions are not installed, go to php.ini to open or install the corresponding extensions, restart nginx and php-fpm, and refresh the page again.
2 if there is a problem with the database connection, there may be a 500 error, but it will be reflected in the log
If you are prompted in the log that there is a problem with the corresponding database connection, you should check to see if the database connection is correct. According to the log, modify the corresponding file, after the database problem is solved, the page will return to normal.
This is the end of this article on "what to do with 500Internal Server Error errors in Nginx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.