系统:在Ubuntu 14.04上运行的LEMP
我正在尝试配置Monit工具,以便在出现问题时重新启动Nginx或PHP-FPM。它正确监控Nginx,但Monit表示它将“不监控”。显然我正在检查错误的位置。
这是我在套接字上运行的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
}
这是我对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
尽管总是使用“service php5-fpm restart”重新启动,但我仍然使用了建议的启动和停止建议。
我的小组 - 根据/etc/php5/fpm/pool.d/www.conf是“group = www-data”。有什么建议吗?
答案 0 :(得分:4)
好的,我能够自己解决。有很多问题。 “php5”需要替换几乎每个“php”的实例。我收到的错误连接是指unixsocket所以我也必须更新它。新的PID位置也改变了它看起来像PHP5-FPM。这是最终配置。
## 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