NGINX – How to Enable and Read PHP-FPM Status Page

By: Sunil Kumar |  In: Server  |  Last Updated: 2019/02/24

One useful feature of PHP-FPM is the built-in health monitoring status page. We’ll show how to enable the status page of PHP – FPM on Linux in this article.

Edit PHP-FPM config

Open the file /etc/php/5.6/fpm/pool.d/www.conf and find

sudo nano  /etc/php/5.6/fpm/pool.d/www.conf

and uncomment the below line –

pm.status_path = /status

this is the url(http://domain_or_IP/status) on which we will be accessing the PHP-FPM status page. You can also change this to any url.

Edit Nginx Conf file

Now open the domain block file

sudo nano /etc/nginx/sites-enabled/domain.conf

and add the location block for the status page

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

Remember to replace your IP address. It’s better to keep your PHP – FPM status page private for security reasons.

Now reload Nginx and PHP-FPM for the changes to take effect

sudo service nginx reload
sudo service php5.6-fpm reload

PHP-FPM status sample

Now open http://domain_or_ip/status to see the fpm status page

pool:                 www
process manager:      dynamic
start time:           24/Feb/2019:08:51:11 +0530
start since:          10846
accepted conn:        15
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       1
active processes:     1
total processes:      2
max active processes: 1
max children reached: 0
slow requests:        0

You can define the output format(JSON, HTML or XML) of the fpm stats as below. default is HTML

http://domain_or_ip/status?json
http://domain_or_ip/status?html
http://domain_or_ip/status?xml

By default, the status page only shows summary of the processes. To print the full status page pass “full” in the query string

http://domain_or_ip/status?full

Reading FPM status page

–pool

the name of the pool. It’s mostly going to be www.

–Process manager

this shows how PHP-FPM create and manage the PHP process. Possible values are static, dynamic or ondemand.

–start time

the date and time when fpm started. Reloading PHP-FPM reset the start time value.

–start since

no of seconds since fpm has started

–accepted connection

no of the connections accepted by the pool

–listen queue

the no of requests in the queue of pending connections.

–max listen queue

the maximum number of requests in the queue of pending connections since FPM has started

–listen queue len

the size of the socket queue of pending connections

–idle processes

the number of idle processes

–active processes

the number of active processes

–total processes

the number of idle + active processes

–max active processes

the maximum number of active processes since FPM has started

–max children reached

the number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase the maximum process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.

–slow requests

Enable PHP-FPM slow-log before you consider this. If this value is non-zero you may have slow PHP processes. Poorly written MySQL queries are the culprit generally.

Conclusion

By now you will be able to enable and read the PHP-FPM status page. You can also enable the Nginx status page on a similar way. You can read below article to enable and read NGINX status page-

How to Enable and Read NGINX Status Page

Comments


Leave a Comment

Your email address will not be published.

*


Sunil Kumar


I am the owner of acmeextension. I am a passionate writter and reader. I like writting technical stuff and simplifying complex stuff.
Know More

Join more than 10,000 others Web Developers


%d bloggers like this: