鍍金池/ 問答/PHP  Linux/ php網(wǎng)站顯示File not found,nginx報錯:FastCGI &q

php網(wǎng)站顯示File not found,nginx報錯:FastCGI "Primary script unknown"

mac上使用homebrew重新安裝了php72版本和nginx,但是配置好nginx.conf和hosts后打開頁面發(fā)現(xiàn)顯示File not found,進入到nginx的error.log中發(fā)現(xiàn)報錯如下:

246#0: *108 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "someline.io"

看了很多網(wǎng)上其他的答案,但都沒能解決問題,所以請大神不吝賜教!萬分感謝~
其中nginx和php-fpm都是默認(rèn)地址:
which nginx查看到nginx地址為:/usr/local/bin/nginx
nginx.conf所在地址為:/usr/local/etc/nginx
which php-fpm查看到php-fpm地址為:/usr/local/sbin/php-fpm
下面是我的nginx配置:

server {
        listen       8080;
        server_name  someline.io;
        root /www/Code/php/someline/public;

        location ~ ^/assets/([a-zA-Z0-9\-_.]+)/ {
            location ~* \.(ttf|ttc|otf|eot|woff|woff2)$ {
                add_header Access-Control-Allow-Origin "*";
            }

            location ~ ^/assets/([a-zA-Z0-9\-_.]+)/(css|js)/.*\.min\.(css|js)$ {
                gzip_static on;
            }
        }

        location / {
             index index.php;
             try_files $uri $uri/ /index.php?$args;
        }

        location ~ ^/index.php$ {
            root /usr/local/etc/nginx/;
            include fastcgi_params;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            proxy_ignore_client_abort on;
        }

        error_page   502 /502-desktop.html;

    }

下面是我hosts配置:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1       someline.io

/var/www的權(quán)限已經(jīng)設(shè)置成chmod -R 777了,對應(yīng)的nginx.conf所在的nginx文件夾也設(shè)置成了chmod -R 777了,但是依然有這個問題。
請大神不吝賜教!謝謝了!

回答
編輯回答
玄鳥

好混亂。。。

先把

    location ~ ^/index.php$ {
        root /usr/local/etc/nginx/;
        

中的 root這樣去掉。 配置中root指的是網(wǎng)站根目錄,你寫這個是啥

2017年7月8日 13:00