23/05/2019 - DOCKER, PHP
If you wish to check if PHP-FPM is running correctly or see it's config without relying on a web server such Nginx or Apache, you can follow the example below.
Install fcgi
package, add lines below to /usr/local/etc/php-fpm.d/www.conf
file and restart PHP-FPM server.
pm.status_path=/status
ping.path=/ping
ping.response=pong
$ SCRIPT_NAME=/ping \
SCRIPT_FILENAME=/ping \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect localhost:9000
X-Powered-By: PHP/7.2.13
Content-type: text/plain;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
pong
$ SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect localhost:9000
X-Powered-By: PHP/7.2.13
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8
pool: www
process manager: dynamic
start time: 21/May/2019:19:25:24 +0000
start since: 38
accepted conn: 5
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 1
active processes: 1
total processes: 2
max active processes: 1
max children reached: 0
slow requests: 0
$ SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
QUERY_STRING=full \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect localhost:9000
X-Powered-By: PHP/7.2.13
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8
pool: www
process manager: dynamic
start time: 23/May/2019:18:37:17 +0000
start since: 824
accepted conn: 7
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 1
active processes: 1
total processes: 2
max active processes: 1
max children reached: 0
slow requests: 0
************************
pid: 6
state: Idle
start time: 23/May/2019:18:37:17 +0000
start since: 824
requests: 3
request duration: 717
request method: GET
request URI: -
content length: 0
user: -
script: /app/index.php
last request cpu: 0.00
last request memory: 2097152
************************
pid: 7
state: Running
start time: 23/May/2019:18:37:17 +0000
start since: 824
requests: 4
request duration: 155
request method: GET
request URI: /status?full
content length: 0
user: -
script: -
last request cpu: 0.00
last request memory: 0
The output above can be printed as in JSON, XML and HTML formats as well by using QUERY_STRING="full&{format}"
. e.g. QUERY_STRING="full&json"
. You can also create a location
block in Nginx config if you want to see these details in browser.
SCRIPT_FILENAME=/app/index.php \
REQUEST_URI= \
QUERY_STRING= \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect localhost:9000
X-Powered-By: PHP/7.2.13
Cache-Control: no-cache, private
Date: Tue, 21 May 2019 19:20:58 GMT
Content-Type: application/json
"UP"
#!/bin/sh
set -e
CMD="SCRIPT_FILENAME=/app/index.php REQUEST_METHOD=GET cgi-fcgi -bind -connect localhost:9000"
RESPONSE=$(eval "$CMD" | tail -1)
echo $RESPONSE # Prints UP