首页 文章

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

提问于
浏览
4

这是来自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

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

相关问题