简体   繁体   English

配置Monit以在Ubuntu / Nginx设置上监视PHP5-FPM

[英]Configure Monit to monitor PHP5-FPM on Ubuntu/Nginx setup

System: LEMP running on Ubuntu 14.04 系统:在Ubuntu 14.04上运行的LEMP

I'm trying to configure the tool Monit to restart Nginx or PHP-FPM if ever there is a problem. 我尝试将工具Monit配置为在出现问题时重新启动Nginx或PHP-FPM。 It is correctly monitoring Nginx however Monit says it will "Not Monitor". 它正在正确监视Nginx,但是Monit表示它将“不监视”。 Apparently I'm having it check the wrong location. 显然我在检查错误的位置。

Here is my Nginx configuration for PHP-FPM that is running on a socket: 这是我在套接字上运行的PHP-FPM的Nginx配置:

location ~ \.php$ { ## Execute PHP scripts
    if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

    expires off; ## Do not cache dynamic content
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params; ## See /etc/nginx/fastcgi_params

    fastcgi_keep_conn on; #hhvm param
}

Here is my Monit configuration for both Nginx and PHP-FPM: 这是我对Nginx和PHP-FPM的Monit配置:

## Check Nginx
check process nginx with pidfile /var/run/nginx.pid
    start program = "/etc/init.d/nginx start"
    stop program = "/etc/init.d/nginx stop"
## Check PHP-FPM
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group www-data #change accordingly
  start program = "/etc/init.d/php5-fpm start"
  stop program  = "/etc/init.d/php5-fpm stop"
  if failed unixsocket /var/run/php-fpm/php-fpm.sock then restart
  if 3 restarts within 5 cycles then timeout

I went with the suggested start and stop recommendations despite always restarting with "service php5-fpm restart". 尽管总是使用“ service php5-fpm restart”重新启动,但我还是采用了建议的启动和停止建议。

My group - according to /etc/php5/fpm/pool.d/www.conf is "group = www-data". 我的群组-根据/etc/php5/fpm/pool.d/www.conf,是“群组= www-data”。 Any suggestions? 有什么建议么?

Ok, I was able to solve it myself. 好的,我自己就能解决。 There were a number of problems. 有很多问题。 "php5" needed to replace almost every instance of "php". “ php5”几乎需要替换“ php”的每个实例。 The bad connection I was receiving was referring to the unixsocket so I had to update that as well. 我收到的错误连接是指unixsocket,因此我也必须对其进行更新。 Also the new PID location changed it looks like with PHP5-FPM. 新的PID位置也发生了变化,与PHP5-FPM相似。 Here is the final configuration. 这是最终配置。

## Check PHP-FPM
check process php5-fpm with pidfile /var/run/php5-fpm.pid
  group www-data #change accordingly
  start program = "/etc/init.d/php5-fpm start"
  stop program  = "/etc/init.d/php5-fpm stop"
  if failed unixsocket /var/run/php5-fpm.sock then restart
  if 3 restarts within 5 cycles then timeout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM