尝试让 monit 适用于 PHP7,但出现连接错误。以下是配置文件:
check process php7.0-fpm with pidfile /run/php/php7.0-fpm.pid
group phpcgi
start program = "/usr/sbin/service php7.0-fpm start"
stop program = "/usr/sbin/service php7.0-fpm stop"
if failed unixsocket /run/php/php7.0-fpm.sock then restart
if 3 restarts within 5 cycles then timeout
有人有什么想法吗?我尝试将 pid 文件位置更改为:/var/run/php/php7.0-fpm.pid,但似乎没有起作用。我还测试了启动和停止命令是否有效,结果确实有效。我还尝试将组更改为 www-data,但也没有用。
答案1
检查 /run/php/php7.0-fpm.sock 是否存在,对我来说它不存在。
有效的方法(假设 php7.0-fpm 正在监听端口 9000):
# Php7.0-fpm
check process php7.0-fpm with pidfile /run/php/php7.0-fpm.pid
stop program = "/usr/sbin/service php7.0-fpm stop"
start program = "/usr/sbin/service php7.0-fpm start"
if failed port 9000 type TCP then restart
if 3 restarts within 5 cycles then alert
答案2
进程名错误,应该是php-fpm不是 php7.0-fpm 像这样:
check process php-fpm with pidfile /run/php/php7.0-fpm.pid
group phpcgi
start program = "/usr/sbin/service php7.0-fpm start"
stop program = "/usr/sbin/service php7.0-fpm stop"
if failed unixsocket /run/php/php7.0-fpm.sock then restart
if 3 restarts within 5 cycles then timeout