6

I've try to get php-fpm status page. When i open /status page in a web browser or directly to fcgi - it says File not found.

Could you help - how to fix this.

# grep -ER "status|ping" /etc/php5/* | grep -v ":;"
/etc/php5/fpm/pool.d/www.conf:pm.status_path = /status
/etc/php5/fpm/pool.d/www.conf:ping.path = /ping
/etc/php5/fpm/pool.d/www.conf:ping.response = pong 

# SCRIPT_NAME=/status SCRIPT_FILENAME=/status QUERY_STRING=  REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
Primary script unknown
Status: 404 Not Found
Content-type: text/html

File not found.

# SCRIPT_NAME=/ping SCRIPT_FILENAME=/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
Primary script unknown
Status: 404 Not Found
Content-type: text/html

File not found.
14

I just had the same problem and I am just going to describe what i needed to make it work. You have not shared many details on your php-fpm config or your nginx (if this is what you are using as a web server). Notice you might need to run the instructions below with sudo/as root in front of the commands to have the rights to modify the files or restart services.

In php-fpm config

vi /etc/php-fpm.d/www.conf

Search for the status path directive and enable it

pm.status_path = /status

Then make sure nginx can call this location. In you nginx site config

vi /etc/nginx/conf.d/mysite.conf

Add

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

Notice above i have commented out the allow and deny instructions to have the status page enabled from any IP. Make sure this is not enabled on production. Now restart both nginx and php-fpm

sudo service nginx restart
sudo service php-fpm restart

Calling the status page from the browser should now work

| improve this answer | |
5

For php7.0 use these codes to enable the status.

In default file in /etc/nginx/sites-available/

location /status {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    log_not_found off;
    }

Uncomment the following line in www.conf (file) in /etc/php/7.0/fpm/pool.d (location)

pm.status_path = /status

Restart both nginx/php7.0

sudo systemctl restart nginx
sudo systemctl restart php7.0-fpm

Now in the web browser, type this address to get a full detailed report of currently running php scripts in the currently active web server where php7.0 is configured to work.

http://yoursite.net/status?html&full

Additionally, make sure to keep it password protected in order to protect it from intruders as explained in here

https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-nginx-on-ubuntu-14-04

| improve this answer | |
1

I had similar issue on Ubuntu 18.04 with PHP 7.2. Found, that these lines were recently added to default snippet/fastcgi-php.conf

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

And since there is no file for pm.status_path - it returns 404;

So, for me - I had to remove include snippet/fastcgi-php.conf

You still need to pass REQUEST_METHOD, QUERY_STRING,SCRIPT_NAME and SCRIPT_FILENAME. Just do it without snippet/fastcgi-php.conf. Often you will have fastcgi.conf, which will work.

| improve this answer | |
1

Mr. Curious was curious about this as well. php-fpm only cares that the SCRIPT_NAME and SCRIPT_FILENAME parameters correspond to the value of pm.status_path setting.

Thus the following is the minimal nginx location to access the status information:

location = /a_random_path_here_ODY1NjY3Mj/fpm-status {
    include fastcgi_params;

    #'/status' is the value of pm.status_path in /etc/php/7.1/fpm/pool.d/www.conf
    fastcgi_param SCRIPT_NAME '/status';
    fastcgi_param SCRIPT_FILENAME '/status';

    fastcgi_pass   unix:/var/run/php/php7.1-fpm.sock;
}

By explicitly stating the parameter values the status page location can be called anything and can be on any path, not just /status. Having a random path also helps prevent generating unnecessary log entries from all kinds of scanners.

In a production setting one would obviously add allow/deny directives or password protection for the location, but the above is the minimal necessary configuration.

One would do a similar thing for the ping uri (ping.path setting) if enabled.

| improve this answer | |
0

Just chipping in since the other answers didn't solve it for me.

All I needed to do (after setting up fpm pool config and the nginx location) was
touch status
in the nginx site root.

I don't know how much of the following is necessary, but it works:

location ^~ /status {
    access_log off;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}

^~ can be replaced with =. Check out https://stackoverflow.com/questions/5238377/nginx-location-priority for more info

| improve this answer | |
-2

If you want to do this from the command line on debian.

as root

watch service php5-fpm status
| improve this answer | |
  • The question was not about whether the process is running or not. – Putnik Oct 18 '16 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.