When you upgrade PHP from 5.3.28 to 5.3.29, Nginx will encounter a 502 error.
Source: Internet
Author: User
This article mainly introduces the 502 error in Nginx when upgrading PHP from 5.3.28 to 5.3.29. if you want to upgrade PHP from 5.3.28 to 5.3.29, you can refer to the following code, the message "502 bad gateway" is displayed. you can access static resources, but access to any php file will be 502.
In fact, I also found this problem before, but I have not found a solution, so I have been keeping PHP in version 5.3.28.
According to my previous temper, I had to get the latest stable version of any software, but software such as PHP is an exception. because of the high version, many programs may be incompatible, relatively speaking, 5.3 compatibility is one of the best versions. of course, 5.2 is also acceptable.
Obsessive-compulsive disorder is really unbearable. the official saying that 5.3.29 is the last version of 5.3. This problem has never been solved in the last version, which makes me very uncomfortable.
I searched the internet and no one encountered this problem. all the compilation and configuration processes were the same as before. Previously, from 5.3.25 to 5.3.28, they used the same upgrade script I wrote, the same sub-Version series, the same compilation and configuration process should not be faulty.
Why is there no problem between 5.3.25 and 5.3.28?
Today, I finally found the root cause of the problem. I am also drunk ......
Since I don't want to use additional ports, Unix socket is always used between Nginx and the PHP-FPM, and it is said that this method is more efficient.
PHP after upgrading to 5.3.29, 502 error, and is a web page opened error, not like due to PHP execution timeout caused by Nginx tip 502, more like PHP-FPM exception terminated, or Ngxin is not connected to fastcgi at all.
The use of PHP-FPM logs is also depressing, I clearly enable the log, but also set the log path, but still did not generate the log.
Well, find out the cause based on the previous ideas:
1. the PHP-FPM ended unexpectedly at the beginning of work;
2. Ngxin is not connected to fastcgi at all.
The first possible directly ruled out, because the 502 error, the background of the PHP-FPM process does not exit, but also well survived.
So it is probably the second possible, I modified the Nginx and PHP-FPM configuration file, changed to the traditional "Address: Port" form
In the PHP-FPM configuration file:
Listen = 127.0.0.1: 1234
In the Nginx configuration file:
Fastcgi_pass 127.0.0.1: 1234
After restarting the service, the website was successfully opened.
It seems that Nginx is not connected to the PHP-FPM, so where is the problem? Does 5.3.29 remove the Unix socket connection method? I think it is unlikely that I can check the update log and see no related projects.
I changed the configuration file for Nginx and PHP-FPM back.
In the PHP-FPM configuration file:
Listen =/tmp/php-cgi.sock
In the Nginx configuration file:
Fastcgi_pass unix:/tmp/php-cgi.sock;
Restart the service and immediately get another 502.
First thought of the Check permissions, anyway is the test, so I did not say directly to the PHP-FPM sock file permissions to 777.
Chmod 777/tmp/php-cgi.sock
Open the webpage directly!
Okay, that's the permission issue. restart the service and check the php-cgi.sock permissions.
-Rwx ------. 1 root 663 September 18 00:16 php-cgi.sock
This... The reason has been very clear, no wonder Nginx can not connect to the PHP-FPM, the php-cgi.sock permission is 700,
But the question is, why is there no problem in versions earlier than 5.3.28 in the same compilation and configuration process? I can see another server without upgrading 5.3.29:
Srw-rw-1 root 0 21:11 php-cgi.sock September 16
It is found that the permission is 666 ...... I cannot understand ...... Why is the default permission configuration of 5.3.28 666 changed to 700 at 5.3.29?
Check the PHP document and find the solution.
Add configuration files in the PHP-FPM, the first two are the owners and user groups of the specified php-cgi.sock, and the last one is the specified file permissions.
Listen. owner = www
Listen. group = www
Listen. mode = 0666
Restart the service and solve the problem.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.