NGINX FASTCGI/PHP - 从上游客户端读取响应标头时主脚本未知


NGINX FASTCGI/PHP - Primary script unknown while reading response header from upstream, client

我有一个开发框,每个用户在主目录中都有一个www文件夹。 NGINX正在托管来自 http://IP 地址/用户名的目录。这很好用。我想让PHP以同样的方式工作。

/

etc/nginx/sites-available-default:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        #root /usr/share/nginx/html;
        #index index.html index.htm;
        # Make site accessible from http://IP ADDRESS/
        server_name IP ADDRESS;
        #location ~ ^/(.+?)(/.*)?$ {
        location ~ ^/(.+?)(/.*)?$ {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                alias /home/$1/www$2;
                index  index.html index.htm index.php;
                include /etc/nginx/php.fast.conf;
                autoindex on;
        }

php.fast.conf 文件:

location ~ '.php$ {
        fastcgi_split_path_info ^(.+?'.php)(/.*)?$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
#       fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
#       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME /home/$1/www$2$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
}

如您所见,我已经尝试了一些变体,但似乎继续在日志中收到以下错误:*1 FastCGI 在 stderr 中发送:"主脚本未知",同时从上游客户端读取响应标头。

尝试呈现简单的 PHP 信息页面时 该页面显示"找不到文件"

其他信息:服务器 = ubuntu 14.x最新恩金克斯数字海滴

提前谢谢。

server {
        listen 80 default_server;
        root /var/www/html;
        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;
        server_name _;
        location ~* '.php$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_split_path_info ^(.+'.php)(/.+)$;
            try_files $fastcgi_script_name =404;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            set $path_info $fastcgi_path_info;
            fastcgi_param PATH_INFO $path_info;
            fastcgi_index index.php;
            include fastcgi_params;
        }
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location ~* ^/(.+?)/www(/.*|/|)$ {
                root /home;
                index index.php index.html;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                # regex to split $uri to $fastcgi_script_name and $fastcgi_path
                fastcgi_split_path_info ^(.+'.php)(/.+)$;
                # Check that the PHP script exists before passing it
                try_files $fastcgi_script_name =404;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                # Bypass the fact that try_files resets $fastcgi_path_info
                # see: http://trac.nginx.org/nginx/ticket/321
                set $path_info $fastcgi_path_info;
                fastcgi_param PATH_INFO $path_info;
                fastcgi_index index.php;
                include fastcgi_params;
        }
        location ~* ^/(.+?)(/.*|/|)$ {
                index index.php index.html;
                try_files $uri $uri/ @home;
        }
        location @home {
                rewrite ^/([^/]+?)$ /$1/www/ last;
                rewrite ^/(.+?)(/.*|/)$ /$1/www$2 last;
        }
}

此配置的缺点是,您不能像/<anything_you_want>/www那样使用URI

也许它有帮助。但它是奇怪的,未优化和丑陋的配置。