I'm trying to set up and get php-fpm stats with a http call. I know it's possible to use the service status command, but I would like to get that from my browser.
I'm running php7, and apache, and this is what I did in my server configuration.
at apache side, I create a vhost with this :
<LocationMatch "/fpm-status">
Order Allow,Deny
Allow from 127.0.0.1
ProxyPass fcgi://127.0.0.1:9000
</LocationMatch>
In the php pool configuration (/etc/php/7.0/fpm/pool.d/www.conf) I have this :
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 1000
pm.start_servers = 150
pm.min_spare_servers = 50
pm.max_spare_servers = 400
pm.max_requests = 200
pm.process_idle_timeout = 5s
pm.status_path = /fpm-status
but after restart apache and php-fpm process, when I try with curl I get this output :
admin@ip-10-3-23-78:~$curl http://localhost/fpm-status
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /fpm-status
on this server.<br />
</p>
</body></html>
admin@ip-10-3-23-78:~$
And in the apache log file I have this :
==> /var/log/apache2/error.log <==
[Thu Aug 25 13:36:10.776665 2016] [access_compat:error] [pid 12608] [client ::1:23142] AH01797: client denied by server configuration: proxy:fcgi://127.0.0.1:9000
I would like to know how to really set this up. I've googled for long time and didn't get a precise answer, every one is trying his way. Who is reponsible to create the status page (fpm-status in my case)? When and how this page is generated (by php-fpm I guess)? What is the right way to set the page up and accessible from a browser?
Might be a bit late now but I wanted to post a straight forward simple answer to this issue with php-fpm(7.1+)/apache(2.4) as most of the answers I found online were a bit convoluted. This is using the default php-fpm settings that require unix sockets vs port mapping.
1) Within /etc/php-fpm.d/www.conf
, I have the following config options set for listen sock below and uncommented out:
listen = /var/run/php-fpm.sock
pm.status_path = /fpm-status
2) With my apache config php-latest.conf
(or similar) I added a match that looked for fpm-status and set it to proxypass
to the unix socket and run the fpm-status from fcgi. It also restricts it so only localhost can call it:
<LocationMatch "/fpm-status">
Order Allow,Deny
Allow from 127.0.0.1
ProxyPass unix:/var/run/php-fpm.sock|fcgi://localhost/fpm-status
</LocationMatch>
3) Just simply run the curl
command locally:
$ curl http://localhost/fpm-status
pool: www
process manager: dynamic
start time: 16/Oct/2019:11:33:25 -0400
start since: 14
accepted conn: 12
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 38
active processes: 2
total processes: 40
max active processes: 5
max children reached: 0
slow requests: 0