gpt4 book ai didi

php - 如何使用 PHP-FPM 和 Nginx Docker 容器解决未知的 PHP-FPM 主脚本?

转载 作者:IT老高 更新时间:2023-10-28 21:40:43 26 4
gpt4 key购买 nike

我的情况是这样的,我有两个 Docker 容器:

  1. 在端口 9000 上运行 PHP-FPM
  2. 运行 nginx 并拥有 PHP 文件(PHP-FPM 容器应该可以访问这些文件吗?)

我不断收到以下错误:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.17.0.1, ser
ver: _, request: "GET / HTTP/1.1", upstream: "fastcgi://172.17.0.2:9000", host: "172.17.0.3"

我读过 here这“总是与 nginx fastcgi_param 指令中错误设置的 SCRIPT_FILENAME 相关。”

问题是,我不知道如何解决:-P

容器 2 中的配置:

server {
listen 80 default_server;
listen [::]:80 default_server;

charset UTF-8;
root /var/www/WordPress;

index index.php index.html index.htm;
server_name _;
location / {
try_files $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass 172.17.0.2:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/WordPress$fastcgi_script_name;
# set headers
add_header Cache-Control $cc;
access_log off;
expires $ex;
}
location ~* \.(js|css|svg|png|jpg|jpeg|gif|ico|eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
add_header Cache-Control "public";
access_log off;
log_not_found off;
expires 1y;
}
location ~ /\.ht {
deny all;
}
}

最佳答案

将根行更改为:root/var/www/WordPress/; for the $fastcgi_script_name 不包括 /

关于php - 如何使用 PHP-FPM 和 Nginx Docker 容器解决未知的 PHP-FPM 主脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41150234/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com