FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,


在對nginx添加fastCGI的支持后,然后進行php頁面驗證,發現頁面識別不到,不清楚什么情況,隨后google了下,原來是Nginx內置變量問題惹的禍。

 

1、平台介紹:

1
2
3
4
5
6
OS Version:        CentOS release  6.4  (Final)
Nginx Version:     nginx version: nginx/ 1.4 . 3
PHP Version:       PHP  5.5 . 5  (fpm-fcgi)
Mysql Version:     Server version:  5.6 . 10 -log Source distribution
Kernel Version:     2.6 . 32 - 358 .el6.x86_64
IP    address:      192.168 . 168.133

 

1
 

2、報錯信息:

1
2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.168.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.168.133"

170203715.jpg

spacer.gif

3、錯誤原因及解決方法:

主配置文件第69行定義調用腳本文件路徑:

1
fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

而Nginx識別不到/scripts路徑,所以phpinfo驗證信息就無法正常通過,需要修改如下:

1
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 

Note:

$document_root 代表當前請求在root指令中指定的值。

我們這里為系統默認,

1
2
3
4
location / {
        root    /usr/local/nginx/html ;
        index  index.php index.html index.htm;
         }

所以該語句就是針對/usr/local/nginx/html目錄下的php文件進行解析。

 

然后再次進行頁面查看已經ok.

170100947.jpg

參考文章:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM