在debian6 + PLESK 12上无法使用nginx激活php-fpm / status | ping -page

时间:2015-02-18 20:54:06

标签: nginx debian php status plesk

我无法获得php-fpm" / status | ping" -page to work。

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

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

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

*配置和文件*

***部分WEB SERVER SETTINGS 激活nginx设置 选中标记:智能静态文件处理 否选中标记:由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"

* script test-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和" BLANK PAGES"或者"访问被拒绝"错误,但没有任何帮助。

根据本指南 (备注:我没有复制那里提到的文件,因为我只想使用plesk) ħ**号码://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

3 个答案:

答案 0 :(得分:1)

由于错误(通过php-fpm)声明,访问被拒绝,因为php-fpm仅限于security.limit_extensions(在你的情况下是.php和.html,这不是你想要的,我想,你不要#39;我想解析.html为.php我想。)

pm.status_path是/ status,它不会以.php(或.html)扩展名结尾,因此会出错。

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

pm.status_path = /status.php

并且也在nginx位置使用它,它可以工作。

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

答案 1 :(得分:0)

这可能无法解决您的问题,但可能会简化它。正则表达式位置是位置敏感的,这可能是有问题的。避免它们以换取一点点重复将排除这一点,并允许您的配置扩展,减少问题。使用“=”位置也有性能优势。

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;
}

答案 2 :(得分:0)

使用以下内容替换nginx.conf上的location ~ ^/(status|ping)$ { allow all; include fastcgi.conf; fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock; }

// This one outputs "subscribe.onError" 
@Test
public void observable_doOnError_subscribingToError() throws InterruptedException {
    Observable<String> obs = getErrorProducingObservable();
    obs.doOnError(throwable -> System.out.println("doOnError"));
    obs.subscribeOn(Schedulers.immediate()).observeOn(Schedulers.immediate()).subscribe(
        s -> {},
        error -> System.out.println("subscribe.onError")
    );
    Thread.sleep(300);
}

// This one outputs "subscribe.onError" 
@Test
public void observable_onErrorReturn() throws InterruptedException {
    Observable<String> obs = getErrorProducingObservable();
    obs.onErrorReturn(throwable -> "Yeah I got this");
    obs.subscribeOn(Schedulers.immediate()).observeOn(Schedulers.immediate()).subscribe(
        s -> System.out.println("got: " + s),
        error -> System.out.println("subscribe.onError")
    );
    Thread.sleep(300);
}

private Observable<String> getErrorProducingObservable()  {
    return Observable.create(subscriber -> {
        subscriber.onError(new RuntimeException("Somebody set up us the bomb"));
    });
}