鍍金池/ 問答/Linux  HTML/ FastCGI sent in stderr: "Primary sc

FastCGI sent in stderr: "Primary script unknown" while reading

多容器搭建 php-fpm + nginx, 在測(cè)試 nginx 的配置是否成功與 fpm 連通時(shí),訪問 url,

每次都報(bào) File not found.

nginx 的日志如下:

clipboard.png

核心的問題: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

docker logs php-fpm 的日志如下:

clipboard.png

nginx 的日志如下:

server {
    listen       80;
    server_name  localhost;
    root /usr/share/nginx/html/;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        fastcgi_pass   php_180227_7.1.0:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

nginx 的共享目錄如下(/home/docker_lnmp/nginx/www:/usr/share/nginx/html):

clipboard.png

php 的共享目錄如下(/home/docker_lnmp/nginx/www:/var/www/html):

clipboard.png

回答
編輯回答
伴謊

nginx 配置文件 config

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

要換成

fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;

不然 php fastcgi解析不了目錄

2017年11月4日 19:54