簡體   English   中英

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

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

我在chroot( archlinux wiki )中安裝了arch linux和nginx。 那是有效的。

現在我想讓 fastcgi 運行。 我將 php-fpm 套接字設置為 127.0.0.1:9000 以從 chroot (/srv/http) 訪問它。

雖然 html 文件打印成功,但 php 文件“未找到”。 在 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".

所以我認為 php-fpm 沒有找到該文件,因為路徑在 nginx chroot 中是絕對路徑,它在真正的根目錄中搜索。 所以我在我的設置中添加了,是的,非常難看,但結果沒有改變。 我怎樣才能調試它,或者更好地找到一個干凈的解決方案?

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
}

坦克很多。

FPM 找錯地方了。

更改您的 php-fpm 配置以在您的訪問日志文件中添加其他信息。 我的服務器是這樣配置的:

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

我的服務器中該配置結果的示例行:

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

按順序,我在訪問日志中使用的這些選項:

  • %t 是當前時間 (07/Sep/2022:19:23:03)。
  • %m 是方法(GET)。
  • %r 是請求 URI (index.php?q=/login)。
  • %Q 是 %q 和 %r (&) 之間的粘合劑。
  • %q 是查詢字符串。 (在我的示例中為空)。
  • %s 是狀態 (200)。
  • %f 是腳本 (/nginx/ech11/public/index.php)
  • %d 是持續時間 µs (23.787)。
  • %M 是 memory (2048)。
  • %C 是 %CPU (21.67%)。

這應該會通知您在 nginx.conf 中更改哪些設置,以使 fpm 能夠找到 index.php 文件。

您可以使用的其他一些選項:

%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