More please support: www.2cto.com
Recently Nginx is often 502, the best way to solve 502 is to restart PHP-FPM.
Manual reboot is still a hassle, and the best thing to do is to throw it into the shell.
Vim restart-php-fpm.sh
#!/bin/sh
service= ' php-fpm '
#if PS ax grep-v grep grep $SERVICE >/dev/null
if NETSTAT-ANP grep 9000 >/dev/null
then
Echo $SERVICE SERVICE running, everything is fine
else
Echo $SERVICE is not running
service php-fpm start
fi
Local virtual machine test a bit, feasible, throw to the server, the results found that 502 did not php-fpm no process, but PHP-FPM zombie.
So there's another option:
Vim restart-php-fpm.sh
#!/bin/bash
my_url=http://www.webyang.net
result= ' curl-i $MY _url grep http/1.1 '
if [N $ Result]; Then
#如果502则会执行这里的内容, casually Add or change
killall-9 php-cgi
service php-fpm Restart
fi
In this case, or manually, 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 on its own request)
*/1 * * * */home/restart-php-fpm.sh
To see if the settings succeeded or failed
Crontab-l
or write a shell dead loop that can be executed in a separate time period.