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

我的情况是这样的,我有两个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" 

我在这里读到,这是“总是与在nginx fastcgi_param指令中错误地设置SCRIPT_FILENAME相关”。

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

configuration容器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/; $fastcgi_script_name不包含/

我不是nginx专家,但是文档中的fastcgi_param SCRIPT_FILENAME每个实例都以$fastcgi_script_name结尾,而您的则不是。