The principle is to use curl to obtain the HTTP header and execute the command to restart PHP-FPM when the 502 status code is found.
CopyCodeThe Code is as follows :#! /Usr/bin/PHP
$ Cmd = '/usr/local/PHP/sbin/PHP-FPM restart ';
For ($ I = 0; $ I $ Res = shell_exec ($ Exec );
If (stripos ($ res, '2014, 502 Bad gateway
The principle is to use Curl to obtain HTTP headers, found 502 status code to perform the restart PHP-FPM command.
Copy Code code as follows:
#!/usr/bin/php
$cmd = '/usr/local/php/sbin/php-fpm restart ';
for ($i = 0; $i $res = Shell_exec ($exec);
if (Stripos ($res, ' 502 Bad Gateway ')!== false) {
S
Today, I set up a WORDPRESS site in the newly installed Linode VPS. Who knows that there was an inexplicable 502 Bad Gateway error when step = 2.20110112200117-156870207 [1]At the beginning of thought is the concurrency and memory problems, adjusted the php-fpm.ini, also re-compiled php. The problem persists. Okay. Check the Centos logs.# Less/var/log/messages //
The 502 error is the one that all nginx running PHP don't want to see.
Nginx 502 has many reasons, but most of the reasons can be attributed to the lack of resources, that is, the back-end php-fpm processing problems, nginx the correct client request to the backend PHP-FPM p
Nginx 502 has many reasons, but most of the reasons can be attributed to the lack of resources, that is, the back-end php-fpm processing problems, nginx the correct client request to the backend PHP-FPM process, However, because of the PHP-FPM process problems caused by the failure to parse the PHP code correctly, finally returned to the client
Server Configuration
CPU model [8 core] Intel (R) Xeon (r) CPU E5620 @ 2.40GHZ | Usage Frequency: 2394.021 | Second-level cache: 12288 KB | bogomips:4788.04x8
Memory 4G
HDD 3 x 300G 15000 turn to RAID 5
WordPress 3.8
CentOS 5.7nginx/1.2.7Php5.2.17p1MySQL 5.1.60
Nginx php mysql These parameters should be how to configure
Reply content:
Server ConfigurationCPU model [8 core] Intel (R) Xeon (r) CPU E5620 @ 2.40GHZ | Usage Frequency: 2394.021 | Secon
Cause1. PHP FastCGI Process count is insufficientWhen the number of concurrent accesses to the website is huge, the number of php fastcgi processes is not guaranteed, because cgi works in a single thread and multiple processes, that is to say, cgi needs to process a page before continuing the next page. If the number of processes is not enough, when the access is huge, cgi processes the previous requests in line, and the subsequent requests will only be abandoned. In this case,
You can try to clear the browser cache access to your FTP to see if you can log in
Successfully resolved 502 Bad Gateway error
Log on Today, show 502 bad Gateway,nginx the most annoyi
introduce
A server (not necessarily a WEB server) is being used as a gateway or proxy to fulfill a request from a customer (such as your browser or our Checkupdown robot) to access the desired URL. To complete the request, this server accesses an upstream server but receives an invalid response.
This usually does not mean that the upstream server is closed (no response to the gateway/proxy), but that the up
seconds from Start could 19:35:21.680742 [NOTICE] Fpm_children_make (), line 352:child 20797 (pool default) started
Inquires the on-line solution, after the modification basically did not have any function, the error is still.
Tried the first method: To change UNIX sockets to TCP/IPModify
The code is as follows
Copy Code
/usr/local/php/etc/php-fpm.cnfWillInside the/tmp/nginx.socketModified into127.0.0.1:9000At the same time,/usr/local/
LNMP common 502 Bad Gateway Problems
When we configure LNMP, we always encounter 502 problems. Whether it is in the browser or using the curl command, it is easy to see "502 Bad Gateway
does not request the server again.
Most users are often so refreshed, encountered 502 of the error will have no effect.
② from the server refresh: If you re-click on the page you want to browse the link, you will find that the page is still showing 502 bad Getway now can be normal browsing!
Do you understand? When you click on the page you want to browse the
A large number of queries often appear 502 bad Gateway
Millions of data were checked directly Nginx 502 bad gateway. Another server is good. I cannot log on to the server to view the co
LNMP upgrade php5.4.28 or later version error 502 bad Gateway
Encounter a very strange problem, with LNMP./upgrade_php.sh upgrade php5.4.27 normal.
But upgrade to php5.4.28 error, Access p.php hint: Nginx 502 bad
PHP program appears 502 bad gateway how to break?
Reply content:
PHP program appears 502 bad gateway how to break?
Confirm that the PHP-FPM process is healthy, and then start with the run environment and adjust the timeout
parameter will not work. The real ability to control the maximum execution time for PHP scripts is the following parameters in the php-fpm.conf configuration file:Attention! The format of the new PHP-FPM in the configuration file is:request_terminate_timeout=0sThe default value is 0 seconds, which means that the PHP script will continue to execute. This way, when all the php-cgi processes are stuck in the file_get_contents () function, the nginx+php
1th: Resource problems caused by request_terminate_timeout if the value of Request_terminate_timeout is set to 0 or too long, it may cause file_get_contents resource problems. If the remote resource requested by file_get_contents is too slow, file_get_contents will remain stuck there and will not time out.We know php.ini inside.Max_execution_timeYou can set the maximum execution time for PHP scripts, but in php-cgi (PHP-FPM), this parameter is not effective. The real ability to control the maxim
Millions of data were checked directly Nginx 502 bad gateway. Another server is good. I cannot log on to the server to view the configuration. Ask you to get nginx+php comrades. What are the settings of your server? I sent it to the hardware department.
Reply to discus
Site Access Tips 502 Bad gateway how to solve. According to the analysis is generally the PHP thread open file handle restricted caused.share in Linux environment site hints 502 Bad Gateway solution
1, raise the file handle
/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(31.055392sec), terminating[ in-dec- . ,: -: One] WARNING: [Pool www] Child9978, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(30.037908SEC), terminatingOpen the php-fpm.conf configuration file, set the Request_terminate_timeout = 30 set of a single script execution more than 30s will be terminated.And in the php.ini config file Max_execution_time = 60, set a sin
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.