Upgrade PHP from 5.3.28 to 5.3 29 o'clock Nginx 502 Error _php Tips

Source: Internet
Author: User
Tags fpm file permissions

Today, the PHP upgrade from 5.3.28 to 5.3.29, found that the site is not open, prompted the "502 Bad Gateway", access to static resources can, but access to any PHP file will be 502.
In fact, I have found this problem before, but have not found a solution, so I always keep PHP in the 5.3.28 version.
According to my previous temper, I have to have the latest stable version of any software, but PHP and other software is the exception, because the version is high, will lead to many programs are incompatible, relatively 5.3 compatibility is one of the best version, of course, 5.2 can also.
Obsessive-Compulsive disorder is really unbearable, the official said 5.3.29 is the last version of 5.3, the last version of this problem has not been resolved to make me very uncomfortable.
Online search for a bit, nobody shows up. This problem, all the compilation process, the configuration process, is the same as before, from 5.3.251 until 5.3.28 are all used by me to write the same upgrade script, according to the same version of the same series, the same compilation and configuration process, should not have problems.
Why 5.3.251 until the 5.3.28 is no problem, 5.3.29 will be no problem?
Today finally found the root of the problem, I was drunk ...
Since I don't want to occupy the extra port, the UNIX sockets that have been used between Nginx and PHP-FPM are said to be more efficient.
PHP upgrade to 5.3.29, there are 502 errors, and it is an error to open the page, unlike the PHP execution timeout caused by the NGINX hint 502, more like a php-fpm abnormal termination, or ngxin is not connected to the fastcgi.
The use of PHP-FPM log is also depressed, I clearly opened the log, but also set the log path, but still did not generate a log.

Well, according to the previous idea, the reason for the problem:

1.PHP-FPM the beginning of the work on the abnormal termination;
2.Ngxin is not connected to the fastcgi at all.

The first may be directly ruled out, because there are 502 errors, the background of the PHP-FPM process and did not quit, but also survived well.
Then it's probably the second possibility, and I've modified the Nginx and PHP-FPM configuration files to the traditional "Address: port" form

PHP-FPM configuration file:

Listen = 127.0.0.1:1234

Nginx configuration file:

Fastcgi_pass 127.0.0.1:1234

Restart the service, the website has successfully opened.

It seems that Nginx is not connected to the PHP-FPM, then the problem is where? Does 5.3.29 get rid of the way UNIX sockets are connected? I do not think it is possible to check the update log and see the relevant items.

I'll change the Nginx and php-fpm configuration files back.
PHP-FPM configuration file:
Listen =/tmp/php-cgi.sock
Nginx configuration file:
Fastcgi_pass Unix:/tmp/php-cgi.sock;
Restart the service, and immediately 502.

First thought of the check permission, anyway is the test, so I apart directly to the PHP-FPM sock file permissions to 777.
chmod 777/tmp/php-cgi.sock
Open the page directly, can open!

Okay, that's right. Restart the service to view Php-cgi.sock permissions

-RWX------. 1 root 663 September 00:16 Php-cgi.sock
This... The reason has been very clear, no wonder nginx not even on the php-fpm,php-cgi.sock of the authority is 700,
But the question is, why is the same compilation and configuration process, before the 5.3.28 version of the problem? I looked for another server that did not upgrade 5.3.29:
Srw-rw-rw-1 root root 0 September 21:11 php-cgi.sock
found that its permission is 666, this ... I can't understand it. Why 5.3.28 Default permission configuration is 666, to 5.3.29 to become 700?
Check the PHP documentation to find a solution

Add the configuration file in the PHP-FPM, the first two are the owner and user group for the specified Php-cgi.sock, and the latter is to specify file permissions.
Listen.owner = www
Listen.group = www
Listen.mode = 0666
Restart the service to solve the problem.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.