php - FastCGI sent in stderr: "Primary script unknown"
迷茫
迷茫 2017-04-11 10:12:53
[PHP讨论组]

我在迁移服务器时需要在新的服务器上配置好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;
        }
    }
}
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号