手动访问PHP-FPM的/ status页面(绕过Apache)


Answers:


12

为了加载/状态页面,你必须具备一定的环境变量设置,具体为:SCRIPT_NAMESCRIPT_FILENAMEQUERY_STRING,和REQUEST_METHOD。您不需要DOCUMENT_ROOT(即使是正常请求)。

在您的php-fpm配置集的正确池(不是全局设置)下(或取消注释):

pm.status_path = /status

然后运行(替换PORT):

SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
QUERY_STRING= \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:PORT

样本输出:

X-Powered-By: PHP/5.3.9
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:                 web1
process manager:      dynamic
start time:           28/Jan/2012:20:49:44 -0500
start since:          5955
accepted conn:        41
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

注意:结果是特定于池的。

在具有PHP v5.3.9的RHEL / CentOS 6系统上进行了测试。

(对于使用CentOS的人来说,值得一提的是-提供的软件包已从EPEL cgi-fcgi命名fcgi并提供)

顺便说一句,使用ping可以实现相同的目的:

设置:ping.path = /ping(php-fpm config)

SCRIPT_NAME=/ping\
SCRIPT_FILENAME=/ping\
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:PORT

或对于常规的PHP文件(您必须使用完整路径,QUERY_STRING是可选的):

SCRIPT_NAME=/test.php \
SCRIPT_FILENAME=/var/www/path/to/test.php \
QUERY_STRING= \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:PORT

有效!!!我已经尝试了(REQUEST_METHOD和DOCUMENT_ROOT和(SCRIPT_NAME或SCRIPT_FILENAME)的每个迭代。谢谢你
mikewaters 2012年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.