PHP-FPM鏄竴涓狿HPFastCGI绠$悊鍣紝鏄彧鐢ㄤ簬PHP鐨勩
php-fpm 宸茬粡鍦 Linux銆丮acOSX銆丼olaris 鍜 FreeBSD 涓婃祴璇曢氳繃銆
纭俊 libxml2锛堝湪鏌愪簺绯荤粺涓婂彨鍋歭ibxml2-devel锛夊凡缁忓畨瑁呫
鍏充簬淇″彿澶勭悊
SIGINT, SIGTERM 绔嬪埢缁堟
SIGQUIT 骞虫粦缁堟
SIGUSR1 閲嶆柊鎵撳紑鏃ュ織鏂囦欢
SIGUSR2 骞虫粦閲嶈浇鎵鏈墂orker杩涚▼骞堕噸鏂拌浇鍏ラ厤缃拰浜岃繘鍒舵ā
鍙傛暟璋冧紭
杩涚▼鏁
棣栧厛锛屾垜浠叧娉ㄤ竴涓墠鎻愯缃細 pm = static/dynamic,鏍囪瘑fpm瀛愯繘绋嬬殑浜х敓妯″紡
static(闈欐) 锛氳〃绀哄湪fpm杩愯鏃剁洿鎺ork鍑簆m.max_chindren涓獁orker杩涚▼
dynamic(鍔ㄦ)锛氳〃绀鸿繍琛屾椂fork鍑簊tart_servers涓繘绋嬶紝闅忕潃璐熻浇鐨勬儏鍐碉紝鍔ㄦ佺殑璋冩暣锛屾渶澶氫笉瓒呰繃max_children涓繘绋嬨
涓鑸帹鑽愮敤static锛屼紭鐐规槸涓嶇敤鍔ㄦ佺殑鍒ゆ柇璐熻浇鎯呭喌锛屾彁鍗囨ц兘锛岀己鐐规槸澶氬崰鐢ㄤ簺绯荤粺鍐呭瓨璧勬簮銆
static:worker杩涚▼ pm.max_children = 300 杩欎釜鍊煎師鍒欎笂鏄秺澶ц秺濂
dynamic:worker杩涚▼ pm.start_servers = 20
dynamic:绌洪棽鐘舵 pm.min_spare_servers = 5 鏈灏弍hp-fpm杩涚▼鏁伴噺
dynamic:绌洪棽鐘舵 pm.max_spare_servers = 35 鏈澶hp-fpm杩涚▼鏁伴噺
max_children
杩欎釜鍊煎師鍒欎笂鏄秺澶ц秺濂斤紝php-cgi鐨勮繘绋嬪浜嗗氨浼氬鐞嗙殑寰堝揩锛屾帓闃熺殑璇锋眰灏变細寰堝皯銆
璁剧疆鈥漨ax_children鈥濅篃闇瑕佹牴鎹湇鍔″櫒鐨勬ц兘杩涜璁惧畾
涓鑸潵璇翠竴鍙版湇鍔″櫒姝e父鎯呭喌涓嬫瘡涓涓猵hp-cgi鎵鑰楄垂鐨勫唴瀛樺湪20M宸﹀彸
鍋囪鈥渕ax_children鈥濊缃垚100涓紝20M*100=2000M
涔熷氨鏄鍦ㄥ嘲鍊肩殑鏃跺欐墍鏈塒HP-CGI鎵鑰楀唴瀛樺湪2000M浠ュ唴銆
鍋囪鈥渕ax_children鈥濊缃殑杈冨皬锛屾瘮濡5-10涓紝閭d箞php-cgi灏变細鈥滃緢绱濓紝澶勭悊閫熷害涔熷緢鎱紝绛夊緟鐨勬椂闂翠篃杈冮暱銆
濡傛灉闀挎椂闂存病鏈夊緱鍒板鐞嗙殑璇锋眰灏变細鍑虹幇504 Gateway Time-out杩欎釜閿欒锛岃屾鍦ㄥ鐞嗙殑寰堢疮鐨勯偅鍑犱釜php-cgi濡傛灉閬囧埌浜嗛棶棰樺氨浼氬嚭鐜502 Bad gateway杩欎釜閿欒銆
start_servers
pm.start_servers鐨勯粯璁ゅ间负2銆傚苟涓攑hp-fpm涓粰鐨勮绠楁柟寮忎篃涓猴細
{锛坈pu绌洪棽鏃剁瓑寰呰繛鎺ョ殑php鐨勬渶灏忓瓙杩涚▼鏁帮級 + 锛坈pu绌洪棽鏃剁瓑寰呰繛鎺ョ殑php鐨勬渶澶у瓙杩涚▼鏁 - cpu绌洪棽鏃剁瓑寰呰繛鎺ョ殑php鐨勬渶灏忓瓙杩涚▼鏁帮級/ 2}锛
鐢ㄩ厤缃〃绀哄氨鏄細min_spare_servers + (max_spare_servers - min_spare_servers) / 2锛
涓鑸岃█锛岃缃垚10-20涔嬮棿鐨勬暟鎹冻澶熸弧瓒抽渶姹備簡銆
鏈澶ц姹傛暟max_requests
鏈澶у鐞嗚姹傛暟鏄寚涓涓猵hp-fpm鐨剋orker杩涚▼鍦ㄥ鐞嗗灏戜釜璇锋眰鍚庡氨缁堟鎺夛紝master杩涚▼浼氶噸鏂皉espawn涓涓柊鐨勩
杩欎釜閰嶇疆鐨勪富瑕佺洰鐨勬槸閬垮厤php瑙i噴鍣ㄦ垨绋嬪簭寮曠敤鐨勭涓夋柟搴撻犳垚鐨勫唴瀛樻硠闇层
pm.max_requests = 10240
褰撲竴涓 PHP-CGI 杩涚▼澶勭悊鐨勮姹傛暟绱Н鍒 max_requests 涓悗锛岃嚜鍔ㄩ噸鍚杩涚▼銆
502锛屾槸鍚庣 PHP-FPM 涓嶅彲鐢ㄩ犳垚鐨勶紝闂存瓏鎬х殑502涓鑸涓烘槸鐢变簬 PHP-FPM 杩涚▼閲嶅惎閫犳垚鐨.
浣嗘槸涓轰粈涔堣閲嶅惎杩涚▼鍛紵
濡傛灉涓嶅畾鏈熼噸鍚 PHP-CGI 杩涚▼锛屽娍蹇呴犳垚鍐呭瓨浣跨敤閲忎笉鏂闀匡紙姣斿绗笁鏂瑰簱鏈夐棶棰樼瓑锛夈傚洜姝 PHP-FPM 浣滀负 PHP-CGI 鐨勭鐞嗗櫒锛屾彁渚涗簡杩欎箞涓椤圭洃鎺у姛鑳斤紝瀵硅姹傝揪鍒版寚瀹氭鏁扮殑 PHP-CGI 杩涚▼杩涜閲嶅惎锛屼繚璇佸唴瀛樹娇鐢ㄩ噺涓嶅闀裤
姝f槸鍥犱负杩欎釜鏈哄埗锛屽湪楂樺苟鍙戜腑锛岀粡甯稿鑷 502 閿欒
鐩墠鎴戜滑瑙e喅鏂规鏄妸杩欎釜鍊煎敖閲忚缃ぇ浜涳紝鍑忓皯 PHP-CGI 閲嶆柊 SPAWN 鐨勬鏁帮紝鍚屾椂涔熻兘鎻愰珮鎬讳綋鎬ц兘銆侾S锛氬垰寮濮嬫垜浠槸500瀵艰嚧鍐呭瓨椋欓珮锛岀幇鍦ㄦ敼鎴5120锛屽綋鐒跺彲浠ュ啀澶т竴浜涳紝10240绛夛紝杩欎釜涓昏鐪嬫祴璇曠粨鏋滐紝濡傛灉娌℃湁鍐呭瓨娉勬紡绛夐棶棰橈紝鍙互鍐嶅ぇ涓浜涖
鏈闀挎墽琛屾椂闂磖equest_terminate_timeout
max_execution_time鍜宺equest_terminate_timeout
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 鈥榤ax_execution_time鈥 ini option
; does not stop script execution for some reason. A value of 鈥0鈥 means 鈥榦ff鈥.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳
璁剧疆鍗曚釜璇锋眰鐨勮秴鏃朵腑姝㈡椂闂. 璇ラ夐」鍙兘浼氬php.ini璁剧疆涓殑鈥檓ax_execution_time鈥欏洜涓烘煇浜涚壒娈婂師鍥犳病鏈変腑姝㈣繍琛岀殑鑴氭湰鏈夌敤. 璁剧疆涓 鈥0鈥 琛ㄧず 鈥極ff鈥.褰撶粡甯稿嚭鐜502閿欒鏃跺彲浠ュ皾璇曟洿鏀规閫夐」銆
杩欎袱椤归兘鏄敤鏉ラ厤缃竴涓狿HP鑴氭湰鐨勬渶澶ф墽琛屾椂闂寸殑銆傚綋瓒呰繃杩欎釜鏃堕棿鏃讹紝PHP-FPM涓嶅彧浼氱粓姝㈣剼鏈殑鎵ц锛岃繕浼氱粓姝㈡墽琛岃剼鏈殑Worker杩涚▼銆
Nginx浼氬彂鐜颁笌鑷繁閫氫俊鐨勮繛鎺ユ柇鎺変簡锛屽氨浼氳繑鍥炵粰瀹㈡埛绔502閿欒銆
鍐呭瓨|CPU鎺掓煡鏂规硶
top
鍛戒护鏍煎紡锛
top [-] [d] [p] [q] [c] [C] [S] [n]
鍙傛暟璇存槑锛
d锛 鎸囧畾姣忎袱娆″睆骞曚俊鎭埛鏂颁箣闂寸殑鏃堕棿闂撮殧銆傚綋鐒剁敤鎴峰彲浠ヤ娇鐢╯浜や簰鍛戒护鏉ユ敼鍙樹箣銆
p锛 閫氳繃鎸囧畾鐩戞帶杩涚▼ID鏉ヤ粎浠呯洃鎺ф煇涓繘绋嬬殑鐘舵併
q锛氳閫夐」灏嗕娇top娌℃湁浠讳綍寤惰繜鐨勮繘琛屽埛鏂般傚鏋滆皟鐢ㄧ▼搴忔湁瓒呯骇鐢ㄦ埛鏉冮檺锛岄偅涔坱op灏嗕互灏藉彲鑳介珮鐨勪紭鍏堢骇杩愯銆
S锛 鎸囧畾绱妯″紡
s 锛 浣縯op鍛戒护鍦ㄥ畨鍏ㄦā寮忎腑杩愯銆傝繖灏嗗幓闄や氦浜掑懡浠ゆ墍甯︽潵鐨勬綔鍦ㄥ嵄闄┿
i锛 浣縯op涓嶆樉绀轰换浣曢棽缃垨鑰呭兊姝昏繘绋嬨傘
m锛氬垏鎹㈡樉绀哄唴瀛樹俊鎭
t锛氬垏鎹㈡樉绀鸿繘绋嬪拰CPU鐘舵佷俊鎭
c锛氬垏鎹㈡樉绀哄懡浠ゅ悕绉板拰瀹屾暣鍛戒护琛屻
M锛 鏍规嵁椹荤暀鍐呭瓨澶у皬杩涜鎺掑簭銆
P锛氭牴鎹瓹PU浣跨敤鐧惧垎姣斿ぇ灏忚繘琛屾帓搴忋
T锛氭牴鎹椂闂/绱鏃堕棿杩涜鎺掑簭銆
sar
鎵цsar -P ALL 1 100銆-P ALL琛ㄧず鐩戞帶鎵鏈夋牳蹇冿紝1琛ㄧず姣1绉掗噰闆嗭紝100琛ㄧず閲囬泦100娆°
寮鍚參鏃ュ織
閰嶇疆杈撳嚭php-fpm鎱㈡棩蹇楋紝闃鍊间负2绉掞細
request_slowlog_timeout = 2
slowlog = log/$pool.log.slow
鍒╃敤sort/uniq鍛戒护鍒嗘瀽姹囨籶hp-fpm鎱㈡棩蹇楋細
grep -v 鈥淾$鈥 www.log.slow.tmp | cut -d 鈥 鈥 -f 3,2 | sort | uniq -c | sort -k1,1nr | head -n 50
鍙傛暟瑙i噴锛
sort: 瀵瑰崟璇嶈繘琛屾帓搴
uniq -c: 鏄剧ず鍞竴鐨勮锛屽苟鍦ㄦ瘡琛岃棣栧姞涓婃湰琛屽湪鏂囦欢涓嚭鐜扮殑娆℃暟
sort -k1,1nr: 鎸夌収绗竴涓瓧娈碉紝鏁板兼帓搴忥紝涓斾负閫嗗簭
head -10: 鍙栧墠10琛屾暟鎹
鐢╯trace璺熻釜杩涚▼
鍒╃敤nohup灏唖trace杞负鍚庡彴鎵ц锛岀洿鍒癮ttach涓婄殑php-fpm杩涚▼姝绘帀涓烘锛
nohup strace -T -p 13167 > 13167-strace.log &
鍙傛暟璇存槑:
-c 缁熻姣忎竴绯荤粺璋冪敤鐨勬墍鎵ц鐨勬椂闂,娆℃暟鍜屽嚭閿欑殑娆℃暟绛.
-d 杈撳嚭strace鍏充簬鏍囧噯閿欒鐨勮皟璇曚俊鎭.
-f 璺熻釜鐢眆ork璋冪敤鎵浜х敓鐨勫瓙杩涚▼.
-o filename,鍒欐墍鏈夎繘绋嬬殑璺熻釜缁撴灉杈撳嚭鍒扮浉搴旂殑filename
-F 灏濊瘯璺熻釜vfork璋冪敤.鍦-f鏃,vfork涓嶈璺熻釜.
-h 杈撳嚭绠瑕佺殑甯姪淇℃伅.
-i 杈撳嚭绯荤粺璋冪敤鐨勫叆鍙f寚閽.
-q 绂佹杈撳嚭鍏充簬鑴辩鐨勬秷鎭.
-r 鎵撳嵃鍑虹浉瀵规椂闂村叧浜,,姣忎竴涓郴缁熻皟鐢.
-t 鍦ㄨ緭鍑轰腑鐨勬瘡涓琛屽墠鍔犱笂鏃堕棿淇℃伅.
-tt 鍦ㄨ緭鍑轰腑鐨勬瘡涓琛屽墠鍔犱笂鏃堕棿淇℃伅,寰绾.
-ttt 寰绾ц緭鍑,浠ョ浜嗚〃绀烘椂闂.
-T 鏄剧ず姣忎竴璋冪敤鎵鑰楃殑鏃堕棿.
-v 杈撳嚭鎵鏈夌殑绯荤粺璋冪敤.涓浜涜皟鐢ㄥ叧浜庣幆澧冨彉閲,鐘舵,杈撳叆杈撳嚭绛夎皟鐢ㄧ敱浜庝娇鐢ㄩ绻,榛樿涓嶈緭鍑.
-V 杈撳嚭strace鐨勭増鏈俊鎭.
-x 浠ュ崄鍏繘鍒跺舰寮忚緭鍑洪潪鏍囧噯瀛楃涓
-xx 鎵鏈夊瓧绗︿覆浠ュ崄鍏繘鍒跺舰寮忚緭鍑.
-a column
璁剧疆杩斿洖鍊肩殑杈撳嚭浣嶇疆.榛樿涓40.
-e execve 鍙褰 execve 杩欑被绯荤粺璋冪敤
-p 涓昏繘绋嬪彿
涔熷彲浠ョ敤鍒╃敤-c鍙傛暟璁﹕trace甯姪姹囨
strace -cp pid
PHP-fpm閰嶇疆鏂囦欢娉ㄩ噴
pid = run/php-fpm.pid
#pid璁剧疆锛岄粯璁ゅ湪瀹夎鐩綍涓殑var/run/php-fpm.pid锛屽缓璁紑鍚
error_log = log/php-fpm.log
#閿欒鏃ュ織锛岄粯璁ゅ湪瀹夎鐩綍涓殑var/log/php-fpm.log
log_level = notice
#閿欒绾у埆. 鍙敤绾у埆涓: alert锛堝繀椤荤珛鍗冲鐞嗭級, error锛堥敊璇儏鍐碉級, warning锛堣鍛婃儏鍐碉級, notice锛堜竴鑸噸瑕佷俊鎭級, debug锛堣皟璇曚俊鎭級. 榛樿: notice.
emergency_restart_threshold = 60
emergency_restart_interval = 60s
#琛ㄧず鍦╡mergency_restart_interval鎵璁惧煎唴鍑虹幇SIGSEGV鎴栬匰IGBUS閿欒鐨刾hp-cgi杩涚▼鏁板鏋滆秴杩 emergency_restart_threshold涓紝php-fpm灏变細浼橀泤閲嶅惎銆傝繖涓や釜閫夐」涓鑸繚鎸侀粯璁ゅ笺
process_control_timeout = 0
#璁剧疆瀛愯繘绋嬫帴鍙椾富杩涚▼澶嶇敤淇″彿鐨勮秴鏃舵椂闂. 鍙敤鍗曚綅: s(绉), m(鍒), h(灏忔椂), 鎴栬 d(澶) 榛樿鍗曚綅: s(绉). 榛樿鍊: 0.
daemonize = yes
#鍚庡彴鎵цfpm,榛樿鍊间负yes锛屽鏋滀负浜嗚皟璇曞彲浠ユ敼涓簄o銆傚湪FPM涓紝鍙互浣跨敤涓嶅悓鐨勮缃潵杩愯澶氫釜杩涚▼姹犮 杩欎簺璁剧疆鍙互閽堝姣忎釜杩涚▼姹犲崟鐙缃
listen = 127.0.0.1:9000
#fpm鐩戝惉绔彛锛屽嵆nginx涓璸hp澶勭悊鐨勫湴鍧锛屼竴鑸粯璁ゅ煎嵆鍙傚彲鐢ㄦ牸寮忎负: 'ip:port', 'port', '/path/to/unix/socket'. 姣忎釜杩涚▼姹犻兘闇瑕佽缃.
listen.backlog = -1
#backlog鏁帮紝-1琛ㄧず鏃犻檺鍒讹紝鐢辨搷浣滅郴缁熷喅瀹氾紝姝よ娉ㄩ噴鎺夊氨琛屻俠acklog鍚箟鍙傝冿細http://www.3gyou.cc/?p=41
listen.allowed_clients = 127.0.0.1
#鍏佽璁块棶FastCGI杩涚▼鐨処P锛岃缃產ny涓轰笉闄愬埗IP锛屽鏋滆璁剧疆鍏朵粬涓绘満鐨刵ginx涔熻兘璁块棶杩欏彴FPM杩涚▼锛宭isten澶勮璁剧疆鎴愭湰鍦板彲琚闂殑IP銆傞粯璁ゅ兼槸any銆傛瘡涓湴鍧鏄敤閫楀彿鍒嗛殧. 濡傛灉娌℃湁璁剧疆鎴栬呬负绌猴紝鍒欏厑璁镐换浣曟湇鍔″櫒璇锋眰杩炴帴
listen.owner = www
listen.group = www
listen.mode = 0666
#unix socket璁剧疆閫夐」锛屽鏋滀娇鐢╰cp鏂瑰紡璁块棶锛岃繖閲屾敞閲婂嵆鍙
user = www
group = www
#鍚姩杩涚▼鐨勫笎鎴峰拰缁
pm = dynamic #瀵逛簬涓撶敤鏈嶅姟鍣紝pm鍙互璁剧疆涓簊tatic銆
#濡備綍鎺у埗瀛愯繘绋嬶紝閫夐」鏈塻tatic鍜宒ynamic銆傚鏋滈夋嫨static锛屽垯鐢眕m.max_children鎸囧畾鍥哄畾鐨勫瓙杩涚▼鏁般傚鏋滈夋嫨dynamic锛屽垯鐢变笅寮鍙傛暟鍐冲畾锛
pm.max_children #锛屽瓙杩涚▼鏈澶ф暟
pm.start_servers #锛屽惎鍔ㄦ椂鐨勮繘绋嬫暟
pm.min_spare_servers #锛屼繚璇佺┖闂茶繘绋嬫暟鏈灏忓硷紝濡傛灉绌洪棽杩涚▼灏忎簬姝ゅ硷紝鍒欏垱寤烘柊鐨勫瓙杩涚▼
pm.max_spare_servers #锛屼繚璇佺┖闂茶繘绋嬫暟鏈澶у硷紝濡傛灉绌洪棽杩涚▼澶т簬姝ゅ硷紝姝よ繘琛屾竻鐞
pm.max_requests = 1000
#璁剧疆姣忎釜瀛愯繘绋嬮噸鐢熶箣鍓嶆湇鍔$殑璇锋眰鏁. 瀵逛簬鍙兘瀛樺湪鍐呭瓨娉勬紡鐨勭涓夋柟妯″潡鏉ヨ鏄潪甯告湁鐢ㄧ殑. 濡傛灉璁剧疆涓 '0' 鍒欎竴鐩存帴鍙楄姹. 绛夊悓浜 PHP_FCGI_MAX_REQUESTS 鐜鍙橀噺. 榛樿鍊: 0.
pm.status_path = /status
#FPM鐘舵侀〉闈㈢殑缃戝潃. 濡傛灉娌℃湁璁剧疆, 鍒欐棤娉曡闂姸鎬侀〉闈. 榛樿鍊: none. munin鐩戞帶浼氫娇鐢ㄥ埌
ping.path = /ping
#FPM鐩戞帶椤甸潰鐨刾ing缃戝潃. 濡傛灉娌℃湁璁剧疆, 鍒欐棤娉曡闂畃ing椤甸潰. 璇ラ〉闈㈢敤浜庡閮ㄦ娴婩PM鏄惁瀛樻椿骞朵笖鍙互鍝嶅簲璇锋眰. 璇锋敞鎰忓繀椤讳互鏂滅嚎寮澶 (/)銆
ping.response = pong
#鐢ㄤ簬瀹氫箟ping璇锋眰鐨勮繑鍥炵浉搴. 杩斿洖涓 HTTP 200 鐨 text/plain 鏍煎紡鏂囨湰. 榛樿鍊: pong.
request_terminate_timeout = 0
#璁剧疆鍗曚釜璇锋眰鐨勮秴鏃朵腑姝㈡椂闂. 璇ラ夐」鍙兘浼氬php.ini璁剧疆涓殑'max_execution_time'鍥犱负鏌愪簺鐗规畩鍘熷洜娌℃湁涓杩愯鐨勮剼鏈湁鐢. 璁剧疆涓 '0' 琛ㄧず 'Off'.褰撶粡甯稿嚭鐜502閿欒鏃跺彲浠ュ皾璇曟洿鏀规閫夐」銆
request_slowlog_timeout = 10s
#褰撲竴涓姹傝璁剧疆鐨勮秴鏃舵椂闂村悗锛屽氨浼氬皢瀵瑰簲鐨凱HP璋冪敤鍫嗘爤淇℃伅瀹屾暣鍐欏叆鍒版參鏃ュ織涓. 璁剧疆涓 '0' 琛ㄧず 'Off'
slowlog = log/$pool.log.slow
#鎱㈣姹傜殑璁板綍鏃ュ織,閰嶅悎request_slowlog_timeout浣跨敤
rlimit_files = 1024
#璁剧疆鏂囦欢鎵撳紑鎻忚堪绗︾殑rlimit闄愬埗. 榛樿鍊: 绯荤粺瀹氫箟鍊奸粯璁ゅ彲鎵撳紑鍙ユ焺鏄1024锛屽彲浣跨敤 ulimit -n鏌ョ湅锛寀limit -n 2048淇敼銆
rlimit_core = 0
#璁剧疆鏍稿績rlimit鏈澶ч檺鍒跺. 鍙敤鍊: 'unlimited' 銆0鎴栬呮鏁存暟. 榛樿鍊: 绯荤粺瀹氫箟鍊.
chroot =
#鍚姩鏃剁殑Chroot鐩綍. 鎵瀹氫箟鐨勭洰褰曢渶瑕佹槸缁濆璺緞. 濡傛灉娌℃湁璁剧疆, 鍒檆hroot涓嶈浣跨敤.
chdir =
#璁剧疆鍚姩鐩綍锛屽惎鍔ㄦ椂浼氳嚜鍔–hdir鍒拌鐩綍. 鎵瀹氫箟鐨勭洰褰曢渶瑕佹槸缁濆璺緞. 榛樿鍊: 褰撳墠鐩綍锛屾垨鑰/鐩綍锛坈hroot鏃讹級
catch_workers_output = yes
#閲嶅畾鍚戣繍琛岃繃绋嬩腑鐨剆tdout鍜宻tderr鍒颁富瑕佺殑閿欒鏃ュ織鏂囦欢涓. 濡傛灉娌℃湁璁剧疆, stdout 鍜 stderr 灏嗕細鏍规嵁FastCGI鐨勮鍒欒閲嶅畾鍚戝埌 /dev/null . 榛樿鍊: 绌.
鎬荤粨绡
502
max_children
request_terminate_timeout銆乵ax_execution_time
鏁版嵁搴
缃戝叧鏈嶅姟鏄惁鍚姩濡俻hp-fpm
504
閿欒涓昏鏌ョ湅nginx.conf鍏充簬缃戝叧濡俧astcgi鐨勯厤缃
request_terminate_timeout璁剧疆0鎴栬呰繃闀块棶棰(502)
濡傛灉璁剧疆涓0鎴栬呰繃闀跨殑鏃堕棿锛屽彲鑳戒細寮曡捣file_get_contents鐨勮祫婧愰棶棰樸
濡傛灉file_get_contents璇锋眰鐨勮繙绋嬭祫婧愬鏋滃弽搴旇繃鎱紝file_get_contents灏变細涓鐩村崱鍦ㄩ偅閲屼笉浼氳秴鏃
鎴戜滑鐭ラ亾php.ini 閲岄潰max_execution_time 鍙互璁剧疆 PHP 鑴氭湰鐨勬渶澶ф墽琛屾椂闂达紝
浣嗘槸锛屽湪 php-cgi(php-fpm) 涓紝璇ュ弬鏁颁笉浼氳捣鏁堛傜湡姝h兘澶熸帶鍒 PHP 鑴氭湰鏈澶ф墽琛屾椂闂寸殑鏄 php-fpm.conf 閰嶇疆鏂囦欢涓殑request_terminate_timeout鍙傛暟銆
淇敼璇ュ弬鏁帮紝璁剧疆 PHP 鑴氭湰鏈澶ф墽琛屾椂闂存槸蹇呰鐨勶紝浣嗘槸锛屾不鏍囦笉娌绘湰銆備緥濡傛敼鎴 30s锛屽鏋滃彂鐢 file_get_contents() 鑾峰彇缃戦〉鍐呭杈冩參鐨勬儏鍐碉紝杩欏氨鎰忓懗鐫 150 涓 php-cgi 杩涚▼锛屾瘡绉掗挓鍙兘澶勭悊 5 涓姹傦紝WebServer 鍚屾牱寰堥毦閬垮厤鈥502 Bad Gateway鈥濄
瑙e喅鍔炴硶鏄痳equest_terminate_timeout璁剧疆涓10s鎴栬呬竴涓悎鐞嗙殑鍊硷紝鎴栬呯粰file_get_contents鍔犱竴涓秴鏃跺弬鏁般
max_requests鍙傛暟閰嶇疆涓嶅綋锛屽彲鑳戒細寮曡捣闂存瓏鎬502閿欒
php-fpm鐨勬參鏃ュ織锛宒ebug鍙婂紓甯告帓鏌ョ
浠ヤ笂灏辨槸php-fpm 涓 Nginx浼樺寲鎬荤粨鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒