简体   繁体   English

PHP-FPM,Monit,ping / status页面,Apache

[英]PHP-FPM, Monit, ping/status pages, Apache

I'm trying to monitor my FPM daemon with Monit, and I'm assuming that the following is not the best technique due to respawning and the PID changing? 我试图用Monit监视我的FPM守护进程,我假设由于重生和PID改变,以下不是最好的技术?

check process php5-fpm with pidfile "/var/run/php5-fpm.pid"
    start = "/etc/init.d/php5-fpm start"
    stop = "/etc/init.d/php5-fpm stop"
    if failed port 80 protocol http then restart

From what I can gather, the better way to do this is to make use of the FPM ping URLs, only I'm unable to activate these with Apache. 从我可以收集的内容来看,更好的方法是使用FPM ping URL,但我无法使用Apache激活它们。

What exactly has to be done in Apache/PHP-FPM, other than setting the FPM pool option: 除了设置FPM池选项之外,Apache / PHP-FPM中究竟需要做什么:

pm.status_path = /status ping.path = /ping pm.status_path = / status ping.path = / ping

which I was hoping would allow me to simply go to: 我希望能让我简单地去:

http://mydomain.com/status http://mydomain.com/status

to pull up the status page. 拉起状态页面。 When I go to this URL I'm getting 404 errors. 当我转到此URL时,我收到404错误。 I'm assuming that I need some sort of handler to redirect /status and /ping to my FPM server on localhost port 9000. How can I do this? 我假设我需要某种处理程序来重定向/ status和/ ping到我的本地主机端口9000上的FPM服务器。我该怎么做?

You would need to set up the default vhost in apache (000-default???) to handle /status and /ping. 您需要在apache(000-default ???)中设置默认vhost来处理/ status和/ ping。 I use nginx (apologies, but adapt as needed) and my default file has the following location directive: 我使用nginx(道歉,但根据需要进行调整),我的default文件具有以下位置指令:

location ~ ^/(status|ping)$ {
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    allow 127.0.0.1;
    deny all;
}

Which then allows me to curl localhost/status . 然后,这允许我curl localhost/status

You also need to change your php-fpm conf (mine is www.conf) and uncomment the lines: 您还需要更改您的php-fpm conf(我的是www.conf)并取消注释行:

pm.status_path = /status
ping.path = /ping

this thread helped me too ... Was getting White "Blank" PHP pages. 这个帖子也帮了我...得到了白色的“空白”PHP页面。

in my /etc/nginx/fastcgi_params added this 在我的/ etc / nginx / fastcgi_params中添加了这个

 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; 

Worked like a charm 工作就像一个魅力

I posted a full Q&A for this relating to the Bitnami LAMP stack here: 我在这里发布了有关Bitnami LAMP堆栈的完整问答:

Set up and access the PHP-FPM status page in Bitnami LAMP stack 在Bitnami LAMP堆栈中设置并访问PHP-FPM状态页面

The details there should also apply to your set-up, but you will probably need to change the Apache config to something like: 那里的细节也应该适用于您的设置,但您可能需要将Apache配置更改为:

<LocationMatch "/php_fpm_status">
  SetHandler php5-fpm
</LocationMatch>

In basic terms, the handler should match whatever name you're using to send files to PHP-FPM in the first place. 在基本术语中,处理程序应该首先匹配您用于将文件发送到PHP-FPM的任何名称。 When using bitnami the relevant conf setting looks like: 使用bitnami时,相关的conf设置如下:

<IfDefine USE_PHP_FPM>
  <Proxy "unix:/path/to/bitnami/php/var/run/www.sock|fcgi://www-fpm" timeout=300>
  </Proxy>
  <FilesMatch \.php$>
    SetHandler "proxy:fcgi://www-fpm"
  </FilesMatch>
</IfDefine>

So, for this set-up, we use: 因此,对于此设置,我们使用:

<LocationMatch "/php_fpm_status">
  SetHandler "proxy:fcgi://www-fpm"
</LocationMatch>

But for any other installation look up what you're using in general for PHP-FPM and then replicate that when setting the handler for your status page. 但是对于任何其他安装,请查找您通常用于PHP-FPM的内容,然后在为状态页面设置处理程序时复制它。

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

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