Skip to content

Instantly share code, notes, and snippets.

@dulao5
Last active November 17, 2021 07:24
Show Gist options
  • Save dulao5/6c6221e95a29b511aad1d8b1f092d202 to your computer and use it in GitHub Desktop.
Save dulao5/6c6221e95a29b511aad1d8b1f092d202 to your computer and use it in GitHub Desktop.
php-fpm status & datadog
location ~ ^/(phpfpm_status|phpfpm_ping)$ {
access_log off;
allow 127.0.0.1;
deny all;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /nginx_status {
allow 127.0.0.1;
deny all;
stub_status;
}
pm.max_spare_servers = 30
pm.process_idle_timeout = 30s;
pm.max_requests = 512
pm.status_path = /phpfpm_status
;pm.max_children = 50
;pm.start_servers = 15
;pm.min_spare_servers = 15
;rlimit_files=65536
;rlimit_core=65536
ping.path = /phpfpm_ping

docker exec -it nginx bash

apt-get update
apt-get install -y curl libfcgi0ldbl


curl http://localhost/nginx_status
Active connections: 1
server accepts handled requests
 8 8 8
Reading: 0 Writing: 1 Waiting: 0
curl http://localhost/phpfpm_status
pool:                 www
process manager:      dynamic
start time:           01/Mar/2019:19:22:21 +0900
start since:          217
accepted conn:        2
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       10
active processes:     1
total processes:      11
max active processes: 1
max children reached: 0
slow requests:        0
curl http://localhost/phpfpm_ping
pong

docker exec -it php_1 bash

cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.9.0
PRETTY_NAME="Alpine Linux v3.9"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
apk update && apk add fcgi

confirm phpfpm status

SCRIPT_NAME=/phpfpm_status SCRIPT_FILENAME="/phpfpm_status" REQUEST_URI="/phpfpm_status" REQUEST_METHOD=GET cgi-fcgi -bind -connect localhost:9000
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:           01/Mar/2019:19:22:21 +0900
start since:          587
accepted conn:        4
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       10
active processes:     1
total processes:      11
max active processes: 1
max children reached: 0
slow requests:        0

confirm phpfpm-ping

SCRIPT_NAME=/phpfpm_ping SCRIPT_FILENAME="/phpfpm_ping" REQUEST_URI="/phpfpm_ping" REQUEST_METHOD=GET cgi-fcgi -bind -connect localhost:9000
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

confirm phpfpm request use fcgi

SCRIPT_NAME="/index.php" SCRIPT_FILENAME="/var/www/html/public/index.php" REQUEST_URI="/test.json" REQUEST_METHOD=GET cgi-fcgi -bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment