Cannot get the PHP-FPM status page on localhost

Hello despite the reading of the topic Enable PHP-FPM Status page, I cannot succeed to access to the FPM status (or even ping locally).

The website is working good and I am able to get the FPM status through a CLI tool.

So I am assuming that my Caddyfile is wrong somehow:
localhost:9000 {
fastcgi /status /var/run/php/php7.2-fpm.sock php
}

with as a test:
wget -O - -q localhost:9000/status

I only get 404.

Thanks in advance.

If the web root contains no status/index.php file, I don’t believe a request to /status would be sent to PHP-FPM at all with your configuration; bear in mind that the php preset indicates that fastcgi should operate in either of these circumstances:

  • The requested file ends in .php, or;
  • The requested directory contains index.php

The above train of thought was what led me to recommend omitting the php preset for the /status endpoint in the previous thread, since doing so will simply send all requests under that base path directly to PHP-FPM.

Thanks for your answer Matthew,

I have removed php preset but without success. My Caddyfile is now:

:9000 {
    errors stderr
    log stdout

    fastcgi /status /var/run/php/php7.2-fpm.sock
}

and the result 404.

28/Mar/2018:02:50:01 +0000 [ERROR 0 /status] Primary script unknown
::1 - - [28/Mar/2018:02:50:01 +0000] "GET /status HTTP/1.1" 404 16

Primary script unknown… Strange.

After some quick research, it seems like everyone recommends setting the fastcgi_params manually in nginx to $document_root$fastcgi_script_name. I’m not sure what exactly that would resolve to, but you could possibly try in your Caddyfule some variations of env SCRIPT_FILENAME /path/to/webroot/status, maybe /status/index.php, etc?

2 Likes

Great ! It worked ! :smile:

This is my final Caddyfile:

:9000 {
    errors stderr
    log stdout

    fastcgi /status /var/run/php/php7.2-fpm.sock {
        env SCRIPT_NAME /status
    }

    fastcgi /ping /var/run/php/php7.2-fpm.sock {
        env SCRIPT_NAME /ping
    }
}

Thank you for your help Matthew !

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.