Please support: http://www.webyang.net/Html/web/article_134.html
Recently nginx often 502, solve 502 the best way is to restart PHP-FPM.
Manual to restart or more troublesome things, the best is to throw into the shell.
Vim restart-php-fpm.sh
#!/bin/shservice=\ ' php-fpm\ ' #if PS Ax | Grep-v grep | grep $SERVICE >/dev/nullif NETSTAT-ANP | grep 9000 >/dev/nullthen echo \ "$SERVICE SERVICE running, everything is fine\" else echo \ "$SERVICE was not Runn ing\ " Service php-fpm Startfi
Local virtual machine test, feasible, throw to the server, the results found that 502 did not php-fpm no process, but PHP-FPM zombie.
So I went. Another option:
Vim restart-php-fpm.sh
#!/bin/bashmy_url=\ "http://www.webyang.net\" result=\ ' curl-i $MY _url | grep \ "http/1.1 502\" \ "if [-n \" $RESULT \ "]; then# If 502 will execute the content here, add or change killall-9 php-cgiservice php-fpm Restartfi
This way, or manual, if you need to automatically add yourself to the crontab.
chmod 755 restart-php-fpm.sh
Run CRONTAB-E
Set restart-php-fpm.sh to be executed automatically every minute (time can be adjusted according to your own requirements)
*/1 * * * */home/restart-php-fpm.sh
To see if a setting succeeds or fails
Crontab-l
or write a shell dead loop, and execute it every other time.