debug, 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, at which time the number of children is automatically controlled by FPM. 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 idle, FPM will actively kill some extra children to conserve resources, and the ser
continuously debug and find a balance point based on the running status of your website.There is also a lazy approach for max_children,If your php is 5.3You can set the fpm style to apache-like. In this case, the number of children is automatically controlled by fpm. The corresponding configuration parameters are:Start_servers: Number of starting processesMin_spare_servers: Minimum number of processesMax_spare_servers: Maximum number of processesWhen the server is idle, fpm will take the initia
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 and not more than 1000 when normal, Google. Found there mentioned
PHP.ini Config Item m
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. 51200
# vi/etc/security/limits.conf? Plus* Soft
The first reason: Install LNMP a key installation package when PHP did not install successfully and 502 bad Gateway, starting from 0.9 as long as the installation of success or failure will be prompted. Failure to install the general reason is that before the installation of PHP, some LIB packages in the script may not be installed, causing PHP failed to compile the installation successfully. You can see if
Tags: lnmp nginx PHPWhen the website was relocated to a new server, it was originally lamp and now changed to lnmp.Change the rewrite file htaccess to nginx Conf. You can only open the home page on a website. When other rewrite pages are opened, they are constantly loaded.Loading will prompt after several minutes502Bad Gateway!......Later, I checked the rewrite rules one by one and found that there was no problem with the program because of the databa
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 cannot increase the number of php-fpm sub-proc
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 cache on the server, this really solves the probl
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 temporarily unavail able) while connecting to up
Nginx + php-fpm error 502 bad gateway solution, nginxphp-fpm
1. nginx error cannot be found. Generally, You need to modify/usr/local/nginx/conf/nginx. conf (careful modification may cause other website problems)
Error 2,502
Case 1: nginx fails:
Command:/usr/local/nginx/sbin/nginx-s reload
Wait a moment later
Case 2: php disconnection:
First you need to modify the parameters in the/usr/local/php-5.6.0/etc/ph
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 /root/php.shAuto-run with crontab settings:crontab-e* * * * * /root/php.shThis article from the "Target: India" blog, reproduced please
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 ')! = False ){Shell_exec ($ cmd );Exit ();}}-->
For crontab, search by Google or re
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 // view log files in the system.The most recent
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 carry on without any time limit.And if you c
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 problem.
(In Php-fpm.conf, the original s
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 PHP log tail–n 1000/usr/local/php/logs/php-fpm
, can set innodb_force_recovery > 0 in MY.CNF
Innodb:and force InnoDB to continue crash recovery here.
You can see the error code is 2, check the MySQL official website error code description is "No such file or directory". Back to the error log, the previous sentence of the error code is "Reading tablespace information from the. ibd files ...", the next sentence is "Error:could not open single-table Tablespa CE file. \dota2\data_abilities-". You can see that the error is related to the *.
Today, after the upgrade of PHP 502 Bad Gateway error, according to experience is PHP-FPM problem, but see what traffic on the Internet, child process settings, but I do not have any traffic on the server. So you can only look at the configuration file.
[Global]
PID =/usr/local/php/var/run/php-fpm.pid
error_log =/usr/local/php/var/log/php-fpm.log
log_level = Notice
[www]
listen =/tmp/php-cgi.sock
user = www
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) {
Shell_exec ($cmd);
Exit ();
}
}
-->
As for crontab, please google search or refer
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.