A machine on the line (which is where the forum is located) has recently appeared frequently 502, and every 100 visits will appear 10 times, which is too high. So I started my 502 troubleshooting trip.
PS aux | grep -C PHP
Result is 200
Netstat-an | grep -C PHP
The result has been under 5, which shows that the php-cgi process is absolutely enough.
View Php-fpm.log
tail -F /usr/local/php/logs/php-fpm.log
No valuable information
View Nginx error Log
Tail -f/usr/local/nginx/logs/error.log
No valuable information
Feel the problem may be in the Nginx configuration, so online find about nginx.conf configuration instructions, change to change to always solve this difficult 502. (The process continues for more than a week, changed n multiple parameters, because there is no value, so I no longer detailed records, here a simple stroke.) )
A few days later, suddenly brainwave, nginx error log since do not error, that the definition of the log level did not meet the requirements to error, so look for information to modify Nginx error log level (default is Crit)
Please refer to http://mylinux.5d6d.net/thread-1289-1-1.html
Finally found valuable information:
Connect () to Unix:/tmp/php-fpm.socket failed ( One and connecting to upstream
Google, and immediately found a way to solve the problem:
Modify Php-fpm.conf
Put
<value name="backlog">-1</value>
Change to:
<value name="backlog">1024x768</value>
This is because, php-fpm in the case that the backlog is set to 1, the backlog number is unlimited, determined by the operating system, and the operating system is determined by the kernel parameter net.core.somaxconn, my operating system the value of this parameter is set to 262144. The value of this parameter defaults to 128, and I think setting it to 262144 is definitely unreasonable. So, I tried it again.
Do not modify the php-fpm.conf, that is, the backlog value is-1, and then change the net.core.somaxconn to the default value of 128, there is no more 502
This article refers to: http://www.360doc.com/content/15/0923/13/27889159_501013998.shtml
Nginx 502 Row Error