【问题标题】:Nginx site for PHP-FPM status page returns "File not found"用于 PHP-FPM 状态页面的 Nginx 站点返回“找不到文件”
【发布时间】:2017-11-13 23:34:13
【问题描述】:

/etc/php/7.1/fpm/pool.d/www.conf 中我设置了pm.status_path = /status。在 Nginx 中我有以下站点配置/etc/nginx/sites-enabled/datadog

server {
  listen 80;
  server_name localhost;

    location ~ ^/(status|ping)$ {
        access_log off;
        allow 127.0.0.1;
        deny all;
        include fastcgi_params;

        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    }
}

我已经测试了状态页面是否正确设置使用

SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /run/php/php7.1-fpm.sock

返回

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:           13/Nov/2017:22:05:44 +0000
start since:          5030
accepted conn:        1789
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       2
active processes:     1
total processes:      3
max active processes: 4
max children reached: 0
slow requests:        0

但是,如果我尝试使用 curl http://localhost/status 访问 Nginx 站点,则会收到以下错误。

2017/11/13 23:32:57 [error] 885#885: *35 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /status HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "localhost"

【问题讨论】:

  • $fastcgi_script_name 的值是多少?看起来可能没有设置...
  • 我该如何测试这个?

标签: php nginx datadog


【解决方案1】:

您正在引用$document_root,但您的服务器块中没有根指令

【讨论】:

  • 我已经尝试设置root /var/www;,但它并没有改变任何事情。我还应该设置其他值吗?
  • 您是否已将您的 fastcgi_params 文件复制到该位置?
猜你喜欢
  • 2017-02-03
  • 2014-08-04
  • 2017-07-30
  • 1970-01-01
  • 2021-04-02
  • 1970-01-01
  • 2019-02-21
  • 2012-01-20
  • 2023-03-07
相关资源
最近更新 更多