簡體   English   中英

NGINX FASTCGI / PHP-從上游客戶端讀取響應頭時,主腳本未知

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

我有一個開發箱,每個用戶的主目錄中都有一個www文件夾。 NGINX正在從http:// IP地址/ USERNAME托管這些目錄。 這很棒。 我想讓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在stderr中發送的FastCGI:“主要腳本未知”,同時從上游客戶端讀取響應頭。

嘗試呈現簡單的PHP信息頁面時,頁面顯示“找不到文件”

其他信息:服務器= ubuntu 14.x最新的Nginx Digital Ocean Droplet

提前致謝。

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。

也許有幫助。 但這是怪異的,未優化的丑陋配置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM