php - FastCGI sent in stderr: "Primary script unknown"

 暧gx祢生 发布于 2022-11-14 07:13

我在迁移服务器时需要在新的服务器上配置好php+nginx环境,但是按照以前的方式配置后发现无法访问页面,查看nginx的错误日志显示:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

在网上找了很多相关的问题答案,一一尝试后仍然无效。
以下是我的nginx配置文件nginx.conf

 server {
        listen       80;
        server_name  localhost;
        root         /var/www/nginx_default/public;
        index        index.php;
        charset      utf-8;

        #access_log /home/wwwlogs/access.log;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        # error_page   500 502 503 504  /50x.html;
        location = /50x.html {
           root   html;
        }
        # redirect server error pages to the static page /50x.html
        #
        # error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}
        location /
            {
                if (!-e $request_filename) {
                rewrite ^/(.*)   /index.php/$1 last;
                }
            }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root                       /var/www/nginx_default/public;
            fastcgi_pass               127.0.0.1:9000;
            fastcgi_index              index.php;
            fastcgi_split_path_info    ^((?U).+\.php)(/?.+)$;  
            fastcgi_param PATH_INFO    $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            #include                   fastcgi_params;
            include                    fastcgi.conf;

        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }
}
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有