用于php-fpm的Monit配置

Ada*_*nez 9 php monit

我很难找到适用于php-fpm的monit配置.

这就是我尝试过的:

### Monitoring php-fpm: the parent process.
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group phpcgi # phpcgi group
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  ## Test the UNIX socket. Restart if down.
  if failed unixsocket /var/run/php-fpm.sock then restart
  ## If the restarts attempts fail then alert.
  if 3 restarts within 5 cycles then timeout
Run Code Online (Sandbox Code Playgroud)

但它失败了,因为没有php-fpm.sock(Centos 6)

Tho*_*don 14

对于在Centos 6上遇到此问题的任何人,php-fpm套接字都在/var/run/php-fpm/php-fpm.sock

因此,最终配置将是这样的:

check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group phpcgi #change accordingly
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  if failed unixsocket /var/run/php-fpm/php-fpm.sock then restart
  if 3 restarts within 5 cycles then timeout
Run Code Online (Sandbox Code Playgroud)


sus*_*ide 6

代替:

if failed unixsocket /var/run/php-fpm.sock then restart
Run Code Online (Sandbox Code Playgroud)

你可以尝试:

if failed port 9000 type TCP then restart
Run Code Online (Sandbox Code Playgroud)

它不需要像本location /ping例那样编辑 lighttpd/nginx 配置。

/etc/monit/conf.d/php-fpm.conf在 Ubuntu 上的样子是这样的:

check process php-fpm with pidfile /var/run/php5-fpm.pid
  stop program = "/sbin/start-stop-daemon --stop --pidfile /var/run/php5-fpm.pid"
  start program  = "/sbin/start-stop-daemon --start --pidfile /var/run/php5-fpm.pid --exec /usr/sbin/php5-fpm"
  if failed port 9000 type TCP then restart
Run Code Online (Sandbox Code Playgroud)


Mar*_*urt 3

我\xc2\xb4m 使用 php-fpm 中的 ping.path 指令来检查它\xc2\xb4s 是否工作...

\n\n

并在 nginx.conf 上配置它(我知道 \xc2\xb4 是否是你的设置)

\n\n
location /ping {\n    access_log     off;\n    allow          127.0.0.1;\n    deny           all;\n    root           html;\n    fastcgi_pass   127.0.0.1:9000;\n    fastcgi_index  index.php;\n    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;\n    include        fastcgi_params;\n}\n
Run Code Online (Sandbox Code Playgroud)\n