During debugging, we often need to isolate problem first to make sure if its really PHP problem or Nginx is doing something wrong.
In those cases, cgi-fcgi
command might come handy.
Installing cgi-fcgi of Ubuntu
Just run following command:
apt-get install libfcgi0ldbl
Connect to PHP-FPM Directly
Assuming you are running PHP-FPM using TCP/IP with IP and PORT values 127.0.0.1 and 9000 respectively, below are some code sample you may want to execute.
Test PHP-FPM Ping Page
You can run following codes from command line to test output:
SCRIPT_NAME=/ping \ SCRIPT_FILENAME=/ping \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect 127.0.0.1:9000
Above will return output like below:
Content-Type: text/plain Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, max-age=0 pong
Test PHP-FPM Status Page
You can run following codes from command line to test output:
SCRIPT_NAME=/status \ SCRIPT_FILENAME=/status \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect 127.0.0.1:9000
Above will return output like below:
Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, max-age=0 Content-Type: text/plain pool: www process manager: dynamic start time: 08/Jan/2014:15:04:57 +0530 start since: 93492 accepted conn: 1215 listen queue: 0 max listen queue: 1 listen queue len: 0 idle processes: 26 active processes: 4 total processes: 30 max active processes: 34 max children reached: 0 slow requests: 150
In case you want to test full status page, you can use commands like:
SCRIPT_NAME=/status \ SCRIPT_FILENAME=/status \ QUERY_STRING=full \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect 127.0.0.1:9000
In case you want to execute custom script, you can specify document root using
SCRIPT_NAME=/custom.php \ SCRIPT_FILENAME=/custom.php \ QUERY_STRING=VAR1 \ DOCUMENT_ROOT=/var/www/example.com/htdocs/ \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect 127.0.0.1:9000