又一个FastCGI主脚本未知错误(nginx,php5-fpm)

时间:2014-10-02 15:11:04

标签: php nginx

这是来自nginx的我的error.log:

  

2014/10/02 14:51:29 [错误] 15936#0:* 1在stderr发送的FastCGI:"主要脚本未知"当从上游读取响应头时,客户端: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复制了它。你们看到任何潜在的问题吗?

1 个答案:

答案 0 :(得分:0)

我提出了一个解决方案,我可以在/etc/nginx/snippets/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;
    }
}