502 ソリューションは php-fpm によく表示されます
もっとサポートしてください: http://www.webyang.net/Html/web/article_134.html
最近 nginx が頻繁に登場502 を解決する最善の方法は、php-fpm を再起動することです。
手動で再起動するのはやはり面倒です。一番良いのはシェルに放り込むことです。
vim restart-php-fpm.sh
<span class="com">#!/bin/sh</span><span class="pln">SERVICE</span><span class="pun">=</span><span class="pln">\'php</span><span class="pun">-</span><span class="pln">fpm\'</span><span class="com">#if ps ax | grep -v grep | grep $SERVICE > /dev/null</span><span class="pln"></span><span class="kwd">if</span><span class="pln"> netstat </span><span class="pun">-</span><span class="pln">anp </span><span class="pun">|</span><span class="pln"> grep </span><span class="lit">9000</span><span class="pln"> </span><span class="pun">></span><span class="pln"> </span><span class="str">/dev/</span><span class="kwd">null</span><span class="pln"></span><span class="kwd">then</span><span class="pln"> echo \"$SERVICE service running</span><span class="pun">,</span><span class="pln"> everything </span><span class="kwd">is</span><span class="pln"> fine\"</span><span class="kwd">else</span><span class="pln"> echo \"$SERVICE </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> running\" service php</span><span class="pun">-</span><span class="pln">fpm start</span><span class="kwd">fi</span>
vim restart-php-fpm.sh
<span class="com">#!/bin/bash</span><span class="pln">MY_URL</span><span class="pun">=</span><span class="pln">\"http</span><span class="pun">:</span><span class="com">//www.webyang.net\"</span><span class="pln">RESULT</span><span class="pun">=</span><span class="pln">\'curl </span><span class="pun">-</span><span class="pln">I $MY_URL </span><span class="pun">|</span><span class="pln"> grep \"HTTP</span><span class="pun">/</span><span class="lit">1.1</span><span class="pln"> </span><span class="lit">502</span><span class="pln">\"\' </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="pun">-</span><span class="pln">n \"$RESULT\" </span><span class="pun">];</span><span class="pln"> </span><span class="kwd">then</span><span class="pln"></span><span class="com">#如果502则会执行这里的内容,随便加或改</span><span class="pln">killall </span><span class="pun">-</span><span class="lit">9</span><span class="pln"> php</span><span class="pun">-</span><span class="pln">cgiservice php</span><span class="pun">-</span><span class="pln">fpm restart</span><span class="kwd">fi</span>
またはシェルの無限ループを書いて実行する一定の時間が経過した後。