Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine which script is being executed in PHP-FPM process

Tags:

php

fastcgi

I am running nginx + php-fpm. Is there any way how can I know what is each of the PHP processes doing? Something like extended mod_status in apache, where I can see that apache process with PID x is processing URL y. I'm not sure if the PHP process knows the URL, but getting the script path and name will be sufficient.

like image 233
Marki555 Avatar asked Feb 22 '13 11:02

Marki555


People also ask

What user is PHP-FPM running as?

By default the web server and php-fpm runs with the user called www-data.

How can I tell if a server is using PHP-FPM?

The best way to tell if it is running correctly is to have nginx running, and setup a virtual host that will fast-cgi pass to PHP-FPM, and just check it with wget or a browser.

What is PHP-FPM doing?

PHP-FPM is an efficient method on how to minimize the memory consumption and rise the performance for the websites with heavy traffic. It is significantly faster than traditional CGI-based methods in multi-user PHP environments.


1 Answers

After some googling hours and browsing PHP.net bug tracking system I have found the solution. It is available since PHP 5.3.8 or 5.3.9, but doesn't seem to be documented. Based on feature request #54577, the status page supports option full, which will display status of each worker separately. So for example the URL will be http://server.com/php-status?full and sample output looks like:

pid:                  22816 state:                Idle start time:           22/Feb/2013:15:03:42 +0100 start since:          10933 requests:             28352 request duration:     1392 request method:       GET request URI:          /ad.php?zID=597 content length:       0 user:                 - script:               /home/web/server.com/ad/ad.php last request cpu:     718.39 last request memory:  1310720 
like image 106
Marki555 Avatar answered Sep 23 '22 21:09

Marki555