无法在debian6+PLESK12上用nginx激活php-fpm/status|ping页面


unable activate php-fpm /status|ping -page with nginx on debian6 + PLESK 12

我无法让php-fpm"/status|ping"页面工作。

一些规格:操作系统Debian 6.0.10Plesk版本12.0.18更新#35,最后更新时间为2015年2月13日08:37 PMPHP版本是5.4.37(从dotdeb获得)

通过PLESK 12 上的升级功能安装了NGINX和PHP-FPM

备注:example.com=my-real-hidden-domain-name.com

*配置和文件*

***WEB服务器设置部分激活的nginx设置选中标记:智能静态文件处理NO复选标记:nginx直接提供静态文件选中标记:通过nginx 处理PHP

***附加nginx指令

location ~ ^/(status|ping)$ {
    allow all;
    fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
    #include /etc/nginx/fastcgi.conf;
    include /etc/nginx/fastcgi_params; # REMARK: not touched
}
location = /nginx_status {
    stub_status on;
}

*PHP设置部分*

cgi.fix_pathinfo=0

在目录/var/www/vhosts/system/example.com/conf下添加了一个自定义php.ini文件

*php.ini争辩道:*

[example.com]
; Don't override following options, they are relied upon by Plesk internally
; Following options can be overridden
 chdir = /
request_slowlog_timeout = 5s
slowlog = /var/www/vhosts/example.com/logs/example.com/slowlog-example.com.log
; By default use on demand spawning (this requires php-fpm >= 5.3.9)
pm = dynamic
pm.max_children = 20
pm.process_idle_timeout = 10s
; Following pm.* options are used only when 'pm = dynamic'
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
env[HOSTNAME] = $HOSTNAME
 env[PATH] = /usr/local/bin:/usr/bin:/bin
 env[TMP] = /tmp
 env[TMPDIR] = /tmp
 env[TEMP] = /tmp
catch_workers_output = yes
pm.status_path = /status
ping.path = /ping
ping.response = bong
security.limit_extensions = .php .html

*php.ini争结束*

*配置和文件结束*

到目前为止,该网站使用此设置运行良好,所有php都通过nginx/php-fpm

*现在是要解决的问题*如果我尝试查看h**p://example.com/status

我得到的只是浏览器中的空白页

*$tail-f/var/log/php5-fpm.log-n 600-s 10*

16-Feb-2015 21:31:52] WARNING: [pool example.com] child 21532 said into stderr: "NOTICE: Access to the script '/status' has been denied (see security.limit_extensions)"

*/var/www/vhosts/example.com/logs/example.com/proxy_access_log*

xxx.xxx.xxx.xxx - - [17/Feb/2015:16:59:11 +0100] "GET /status HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:37.0) Gecko/20100101 Firefox/37.0"

*脚本测试-php-fpm.sh:*

SCRIPT_NAME=/status '
SCRIPT_FILENAME=/status '
QUERY_STRING= '
REQUEST_METHOD=GET '
cgi-fcgi -bind -connect /var/www/vhosts/system/example.com/php-fpm.sock

脚本结束*$/test-php-fpm.sh通过SSH输出:*

Access to the script '/status' has been denied (see security.limit_extensions)
Status: 403 Forbidden
Content-type: text/html
Access denied.

*输出结束(空行是否有"输出?"*

$ curl http://example.com/status 

只输出NOTHING

*ls-l/var/www/vhosts/system/example.com/php-fpm.sock*

srw-rw---- 1 root psaserv 0 Feb 15 19:58 /var/www/vhosts/system/example.com/php-fpm.sock

根据一些教程,它应该可以工作,但不能。

我试着在互联网上搜索不同的解决方案PHP-FPM NGINX和"空白页面"或"拒绝访问"错误,但没有任何帮助。

根据本指南(备注:我没有复制上面提到的文件,因为我只想使用plesk)h**p://timreeves.de/internet-technologie/server-tuning-2-nginx-und-php-fpm-unter-ubuntu-12-04-lts-und-plesk-11-5/

我也做

$ usermod -aG psacln nginx 

我不想通过TCP/IP,请保留套接字文件。有人能给我个建议吗。

mfg/wkr

正如错误(由php fpm)所述,访问被拒绝,因为php fpm被限制为security.limit_extensions(在您的情况下是.php和.html,我认为这不是您想要的,我想您不想将.html解析为.php)。

pm.status_path是/status,它没有以.php(或.html)扩展名结尾,因此出现了错误。

当我自己遇到这个问题并在谷歌上找到你的问题时,我告诉你我的解决方案是设置:

pm.status_path = /status.php

并在nginx位置使用它,它也能工作。

另一种解决方案是允许php-fpm运行任何没有扩展名限制的文件(将空设置为security.limit_extensions),但我认为这不是一个好主意。

这可能无法解决您的问题,但可能会简化它。Regex位置对位置敏感,这可能会有问题。避免它们以换取一点重复将排除这种情况,并允许您的配置以更少的问题进行扩展。使用"="位置还有一个性能优势。

location = /status {
    allow all;
    fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
    include /etc/nginx/fastcgi_params;
}
location = /ping {
    allow all;
    fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
    include /etc/nginx/fastcgi_params;
}
location = /nginx_status {
    stub_status on;
}

nginx.conf上的location替换为:

location ~ ^/(status|ping)$
{
    allow all;
    include fastcgi.conf;
    fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
}