简体   繁体   English

Php-fpm 找不到来自 chroot 的 nginx 的文件

[英]Php-fpm does not find the files from the chrooted nginx

I installed arch linux and nginx in a chroot ( archlinux wiki ).我在chroot( archlinux wiki )中安装了arch linux和nginx。 Thats working.那是有效的。

Now I want to get fastcgi running.现在我想让 fastcgi 运行。 I set the php-fpm socket to 127.0.0.1:9000 to reach it from the chroot (/srv/http).我将 php-fpm 套接字设置为 127.0.0.1:9000 以从 chroot (/srv/http) 访问它。

While the html files are printed successfully the php-files are "not found".虽然 html 文件打印成功,但 php 文件“未找到”。 In the nginx-log I found this:在 nginx 日志中,我发现了这个:

FastCGI sent in stderr: "primary script unknown" while reading response header from upstream, client: 10.211.55.2, server: localhost, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000:, host: "10.211.55.6".

So I think the php-fpm does not found the file, because the path is absolute in the nginx chroot and it searches in the real root.所以我认为 php-fpm 没有找到该文件,因为路径在 nginx chroot 中是绝对路径,它在真正的根目录中搜索。 So I added, yes very ugly, the following to my settings, but there is no change of the result.所以我在我的设置中添加了,是的,非常难看,但结果没有改变。 How can I debug it, or better, find a clean solution?我怎样才能调试它,或者更好地找到一个干净的解决方案?

location ~ \.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME  /srv/http$document_root$fastcgi_script_name
}

Tanks a lot.坦克很多。

FPM is looking in the wrong place. FPM 找错地方了。

Change your php-fpm configuration to add additional information on your access log file.更改您的 php-fpm 配置以在您的访问日志文件中添加其他信息。 My server is configured this way:我的服务器是这样配置的:

[www]
access.format = "%t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

A sample line of the result of that configuration from my server:我的服务器中该配置结果的示例行:

07/Sep/2022:19:23:03 -0400 "GET index.php?q=/login&" 200 /nginx/ech11/public/index.php 23.787 2048 21.67%

In order, these options I use in my access logs:按顺序,我在访问日志中使用的这些选项:

  • %t is the current time (07/Sep/2022:19:23:03). %t 是当前时间 (07/Sep/2022:19:23:03)。
  • %m is the method (GET). %m 是方法(GET)。
  • %r is the request URI (index.php?q=/login). %r 是请求 URI (index.php?q=/login)。
  • %Q is the glue between %q and %r (&). %Q 是 %q 和 %r (&) 之间的粘合剂。
  • %q is the query string. %q 是查询字符串。 (empty in my example). (在我的示例中为空)。
  • %s is the status (200). %s 是状态 (200)。
  • %f is the script (/nginx/ech11/public/index.php) %f 是脚本 (/nginx/ech11/public/index.php)
  • %d is the duration µs (23.787). %d 是持续时间 µs (23.787)。
  • %M is the memory (2048). %M 是 memory (2048)。
  • %C is the %CPU (21.67%). %C 是 %CPU (21.67%)。

That should inform you which settings to alter in the nginx.conf to enable fpm to find the index.php file.这应该会通知您在 nginx.conf 中更改哪些设置,以使 fpm 能够找到 index.php 文件。

Some other options you can use:您可以使用的其他一些选项:

%e  fastcgi env
%l  content length
%n  pool name
%o  header output
%p  PID
%T  time

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM