4
votes

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?

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.

What exactly has to be done in Apache/PHP-FPM, other than setting the FPM pool option:

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

which I was hoping would allow me to simply go to:

http://mydomain.com/status

to pull up the status page. When I go to this URL I'm getting 404 errors. 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?

3

3 Answers

11
votes

You would need to set up the default vhost in apache (000-default???) to handle /status and /ping. I use nginx (apologies, but adapt as needed) and my default file has the following location directive:

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.

You also need to change your php-fpm conf (mine is www.conf) and uncomment the lines:

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

this thread helped me too ... Was getting White "Blank" PHP pages.

in my /etc/nginx/fastcgi_params added this

fastcgi_param PATH_TRANSLATED   $document_root$fastcgi_script_name;

Worked like a charm

1
votes

I posted a full Q&A for this relating to the Bitnami LAMP stack here:

Set up and access the PHP-FPM status page in Bitnami LAMP stack

The details there should also apply to your set-up, but you will probably need to change the Apache config to something like:

<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. When using bitnami the relevant conf setting looks like:

<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.