Need a simple How-To for adding PHP-FPM Status

IT_Architect

Verified User
Joined
Feb 27, 2006
Messages
1,091
Server Setup:
FreeBSD 11.2, Apache 2.4.37, PHP-FPM 5.3.29 and PHP-FPM 7.2.12, DirectAdmin 1.61.3 (latest)

Entries made on server:
1. Edit: /usr/local/php53/etc/php-fpm.conf and uncomment: "pm.status_path = /status"
2. In the control panel at the admin level click on Custom HTTPD Configurations, then the userdomain.tld, expand Custom 1, paste in the following code:
<FilesMatch "^ping|status$">
RewriteEngine Off
SetHandler "proxy:unix:/usr/local/php53/sockets/user.sock|fcgi://localhost"
</FilesMatch>
and press save.
3. Restart php-fpm53

Open browser on workstation and type in address bar:

Browser Results:
File not found.
 
Last edited:
Apparently not many people do this. The other threads are from 2014-2018 and the methods they spell out no longer work. When I find out how to do it today, I will post it here.
 
It works with the webapps pool
<FilesMatch "^ping|status$">
RewriteEngine Off
SetHandler "proxy:unix:/usr/local/php53/sockets/webapps.sock|fcgi://localhost"
</FilesMatch>
Not the user name pool
SetHandler "proxy:unix:/usr/local/php53/sockets/username.sock|fcgi://localhost"

Perhaps this will turn out to be a rights issue.
 
Last edited:
After reading all 3 posts in this forum and some other 3-4 posts in the other forums I got only one successful result by using IP address (which is mapped to webapps.sock via global httpd .conf). Like what you said above.

I tried to set it up for other users' domains with the suggestion at https://forum.directadmin.com/threads/setup-php7-fpm-status-page-for-apache-2-4.54689/ without success. There are only "File not found" displayed in browser and "[procy_fcgi:error] ... AH01071: Got error 'Primary script unknown\n'" logged in domain.error_log, indicating that the php handler is really called but found nothing.

Then I found your conclusion above, saying that the other threads and methods are no longer work, I nearly stop trying it.

However I tried to translate the suggestion at the thread again and again. Finally I got the expected result, and I hope this is useful for you too.

The following is an example for multiple versions of PHP-FPM, which is my use case.

What you have to do are;
1. Modify /usr/local/directadmin/data/templates/custom/virtual_host2*.conf (4 files for main domain, subdomains, and all https of them) by adding these lines into <VirtualHost> section outside any <Directory>. For me, I add them just before closing </VirtualHost>. Use the filename you want. (For me I want it as 'fpmXX-status')

Code:
|*if HAVE_PHP1_FPM="1"|
        <FilesMatch "^fpm|PHP1_RELEASE|-status$">
                RewriteEngine Off
                SetHandler "proxy:unix:/usr/local/php|PHP1_RELEASE|/sockets/|USER|.sock|fcgi://localhost"
        </FilesMatch>
|*endif|
|*if HAVE_PHP2_FPM="1"|
        <FilesMatch "^fpm|PHP2_RELEASE|-status$">
                RewriteEngine Off
                SetHandler "proxy:unix:/usr/local/php|PHP2_RELEASE|/sockets/|USER|.sock|fcgi://localhost"
        </FilesMatch>
|*endif|

2. Modify /usr/local/directadmin/data/templates/custom/php-fpm.conf by adding the following line (with the filename you use in the virtual_host2*.conf) after the line of pm.max_requests.

Code:
pm.status_path = /fpm|PHP_VER|-status

3. Rewrite configs with ./build rewrite_confs

Remark:
1. Everytime I added '-ping' by usgin "^(fpm|PHP2_RELEASE|-ping|fpm|PHP2_RELEASE|-status)$" in vhost*.conf and add "ping.path = /fpm|PHP_VER|-ping" in php-fpm.conf, this feature is failed to use. So I removed them.
2. If these files are missing in the directory 'custom', copy them from /usr/local/directadmin/data/templates/config/.
3. I'm not sure is there anything about enabling/disabling /server-status or not (as I have seen in some threads). I enable it for a long time until now.

Note:
a) The FilesMatch settings are per domain. The PHP settings are per user.
b) You must NOT set the <FilesMath "fpmXX-status"> in the global httpd .conf file otherwise you cannot access this feature via the URLs of other users.
c) The other way is to add these settings via "Custom HTTPD Configurations" in DirectAdmin control panel which you can set it per domain.
d) If you want to use the UI "status.html" bundled with PHP, which is user-friendly come with auto-refresh, you may add the following lines in httpd-includes.conf. (Don't forget to edit the auto-generated URL in status.html with your chosen filename.)

Code:
<IfModule alias_module>
  Alias /phpXX-status "/usr/local/phpXX/php/php/fpm/status.html"
</IfModule>

Hope this helps.
 
Last edited:
Back
Top