On the Saturday game not to go, their own tools to test, the hint 502 bad gateway error, not know how the whole, unexpectedly put the server restarted, and so the boss of the verification code, tossing the majority of days, in fact, not so, direct birth php5-fpm, and Nginx can
/ETC/INIT.D/PHP5-FPM restart
Service Nginx Restart
If reboot fails
If prompted fail sud
occur during installation and use. Generally, the default PHP-CGI process is five, which may be caused by insufficient phpcgi processes, you need to modify/usr/local/PHP/etc/php-fpm.conf to add the max_children value as appropriate. It is also possible that the max_requests value is insufficient. It must be noted that this configuration item occupies a large amount of memory. Please set it according to the server configuration. Otherwise, it may have a negative effect.
Iv. PHP Execution timeout
A simple script to monitor 502, and if it encounters 502, automatically restarts the PHP process. Suitable for LNMP environments.The following files are stored in/root or other directories:#!/bin/bashMY_URL="http://www.tarena.com.cn/"RESULT=`curl -I $MY_URL|grep"HTTP/1.1 502"`if[ -n "$RESULT"]; then/etc/init.d/php-fpm restartfiGive executable permission:chmod+x /
by the page consumption of our site may be too large.
On the Internet to find a solution, in the foreign site saw a way to increase the buffer, thoroughly solve the problem of Nginx 502 bad Gateway. The method is as follows:
HTTP {
...
Fastcgi_buffers 8 16k;
Fastcgi_buffer_size 32k;
...
}
Increase the above two configuration items by yourself, depending
There was a strange problem today when the form was submitted directly 502 bad gateway! Begin to suspect is a program problem, then check the program is normal, found that post field number is greater than 1000 when 502 bad Gateway
PHP thread open File handle limited error 502 bad Gateway
The resources on the Internet are basically considered to be errors caused by the limited opening of a file handle by a PHP thread. The specific solution is as follows:
?
1. Raise the file handle of the server open Open
/etc/security/limits.conf: (Increase)
* soft???????? 51200
*?????? nofile. 5120
Output Log configuration:http://blog.csdn.net/wzy_1988/article/details/8486888Solution:Http://www.cnblogs.com/jackluo/p/3366612.htmlAbout the 502 solution caused by file_get_contents:Http://www.111cn.net/phper/php-function/55873.htmHttp://www.qetee.com/share/php-fpm-cpu100.htmlReplace the system's own file_get_contents with the file_get_content function of your own package= stream_context_create (Array ( 'http' = = Array (' Timeout'// s
There are 502 errors in php-cgi processes, long PHP execution time, or php-cgi process death.
1). Long PHP Execution Time
If the server performance is good enough and the broadband resources are sufficient, the PHP script does not have a loop or bug, you can set the "request_terminate_timeout" to 0s directly.PHP-FPM.CONF 103 lines Around
The code is as follows
Copy Code
The meaning of 0s is to allow php-cgi to
After buying a cloud server, the system automatically installs the Nginx 1.6 + PHP 5.3.28 + mysql 5.5
After the PHP program into the cloud server, the first test program access to normal, normal speed
But put the program on the line after the visit, will gradually find that access to the PHP page more and more slowly, and finally directly appear 502 bad gateway
Received an alert email today prompting the website 502 Bad Gateway,You cannot open the Web site URL after entering it:Log on to the server to see Nginx process OK:To view the FASTCGI process has stopped running:Problems found after the search is what the cause of the problem, the first fastcgi process started after the site can access the reasons for fine.View P
, find a balance point.
There's also a lazy approach to max_children,
If your PHP is 5.3, then you can set the FPM style to Apache-like, this time the number of children by FPM automatic control. The corresponding configuration parameters are
Start_servers: Number of start processes
Min_spare_servers: Minimum number of processes
Max_spare_servers: Maximum number of processes
When the server is more idle, FPM will take the initiative to kill some redundant children, to save resources, when the se
error occurs. You can increase memory_limit of php. ini to 64 MB.Other causes that may cause 502 bad gateway errorsInsufficient. php-fpm process countUse netstat-napo | grep "php-fpm" | wc-l to check the number of fastcgi processes. If the number is close to the upper limit configured in conf, you need to increase the number of processes.However, you c
Nginx 502 Bad Gateway can be forcibly refreshed by the client, but the solution is either to change the configuration or put it on the CDN. In this case, someone found that index.html can be accessed. Because we are an online website and do not have much time to study it, this is temporary. Then, someone suggested that Ctrl + F5 should be used to refresh the cach
corresponding ports on the queue is full of two casesThe somaxconn of the system can be modified in the following wayVim/etc/sysctl.confNet.core.somaxconn = 2048Sysctl-pIn PHP-FPM, there is an option for thisListen.backlog =-1This value, preferably not set to-1, 1 when the system is not able to set the number of settings, resulting in 502 appears2015/02/11 12:37:22 [ERROR] 25725#0: *1015645 connect () to Unix:/tmp/php-cgi.sock failed (11:resource tem
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
Nginx can receive 80 requests, but cannot go to tomcat:8080.
Direct access to Http://x.x.x.x:8080/project can be accessed
View/var/log/nginx/error.log
2015/04/01 11:38:13 [crit] 2895#0: *10 connect () to 127.0.0.1:8080 failed (13:permission denied) while connecting to Upstream, client:10.12.70.206, server:localhost:8080, Request: "GET/BPP http/1.1", Upstream: "http://127.0.0.1:8080/ App ", Host:" 10.11.202.204 "
Solution:
Http://stackoverflow.com/questions/25235453/nginx-proxy-server-localhost-
[ArticleAuthor: Zhang banquet this article version: V1.0 last modified: 2008.07.30 reprint please indicate the original article link: http://blog.s135.com/read.php/361/]
Yesterday, a friend asked me how to solve the "502 Bad Gateway" error when he changed the Web server to nginx 0.6.31 + PhP 4.4.7 (FastCGI.
I will follow the two steps below to 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.