【问题标题】:Yet another FastCGI Primary Script Unknown error (nginx, php5-fpm)又一个 FastCGI Primary Script Unknown 错误(nginx、php5-fpm)
【发布时间】:2014-11-27 15:01:01
【问题描述】:

这是我来自 nginx 的 error.log:

2014/10/02 14:51:29 [error] 15936#0: *1 FastCGI sent in stderr: "Primary script unknown" 同时从上游读取响应标头,客户端:134.106.87.55,服务器:sumomo.shitteru2 .net,请求:“GET /index.php HTTP/1.1”,上游:“fastcgi://unix:/var/run/php5-fpm.sock:”,主机:“sumomo.shitteru2.net”

这是我启用的网站:

server {
     listen 80;
     server_name sumomo.shitteru2.net;

     index index.php index.html index.htm;

     location / {
             root /mnt/firstsite;
     }

     location ~ [^/]\.php(/|$) {
             fastcgi_split_path_info ^(.+?\.php)(/.*)$;
             if (!-f $document_root$fastcgi_script_name) {
                     return 404;
             }
             fastcgi_pass unix:/var/run/php5-fpm.sock;
             fastcgi_index index.php;
             include fastcgi_params;
     }
}

据我所知,一切都非常简单,所以它应该可以工作。我什至直接从http://wiki.nginx.org/PHPFcgiExample#Connecting_nginx_to_PHP_FPM 复制了它。你们有没有发现任何潜在的问题?

【问题讨论】:

标签: php nginx


【解决方案1】:

我在 /etc/nginx/sn-ps/common.conf 中创建了一个可以在任何地方使用的解决方案:

index index.php index.html index.htm index.nginx-debian.html;
location ~ \.php$
{                                                                                
    include snippets/fastcgi-php.conf;                                                                                      
    # With php5-fpm:                                                                                                        
    fastcgi_pass unix:/var/run/php5-fpm.sock;    
}

现在我所有的站点配置文件看起来都非常简单:

server {
    listen 80;
    listen [::]:80;

    server_name do-it-big.com www.do-it-big.com;
    root /var/www/doitbig;
    client_max_body_size 10m;
    include snippets/common.conf;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
}

【讨论】:

    猜你喜欢
    • 2023-02-06
    • 2015-03-14
    • 2012-05-15
    • 1970-01-01
    • 2011-03-12
    • 2014-07-07
    • 2011-10-09
    • 2016-02-24
    • 1970-01-01
    相关资源
    最近更新 更多