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

Bob*_*ijt 6 php nginx docker

我的情况是这样的,我有两个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"
Run Code Online (Sandbox Code Playgroud)

在这里读到,这"总是与SCRIPT_FILENAMEnginx fastcgi_param指令中的错误设置有关."

问题是,我不知道如何解决它:-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;
    }
}
Run Code Online (Sandbox Code Playgroud)

Jas*_*eng 5

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