2013-03-22 112 views
0

我的操作系統:Ubuntu的12.10 Web服務器環境是:Nginx的+ PHP-FPM奇怪的網絡服務器問題

安裝的基於on this tutorial

這裏是網站的nginx的conf文件

server { 
set $host_path "path_to_website"; 

server_name website.local; 

root $host_path; 
set $yii_bootstrap "index.php"; 

charset utf-8; 
index index.php index.html; 

log_not_found off; 

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

    location ~ ^/(protected|framework|themes/\w+/views) { 
    deny all; 
    } 

    #avoid processing of calls to unexisting static files by yii 
    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 
    try_files $uri =404; 
} 


location ~ \.php$ { 
    fastcgi_split_path_info ^(.+\.php)(.*)$; 
    #let yii catch the calls to unexising PHP files 
    set $fsn /$yii_bootstrap; 
    if (-f $document_root$fastcgi_script_name){ 
     set $fsn $fastcgi_script_name; 
    } 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 

location ~ /\.ht { 
    deny all; 
} 

}

順便說一句,這個配置是optimized for Yii framework

問題是,當我試圖進入該網站,獲得以下錯誤:

File not found. 

當我打開nginx的error.log文件,我看到以下內容

2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET/HTTP/1.1", host: "website.local" 
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET/HTTP/1.1", host: "website.local" 
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_websiteindex.php" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET/HTTP/1.1", host: "website.local" 
2013/03/22 23:36:45 [error] 14388#0: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: website.local, request: "GET/HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "website.local" 

我100%確定關於網站的路徑,並且還添加到主機文件website.local。也是chown遞歸遞歸的整個父目錄,其中網站位於。

我不明白什麼是問題。 PLease幫助我解決這個問題。我可以給任何想要幫助的人提供遠程訪問。

注:

我剛剛更換的真實路徑與此path_to_website信心。就這樣。有真實路徑

+0

你爲什麼設置$ fsn但從來沒有使用它? – 2013-03-23 02:37:13

回答

0
set $host_path "path_to_website"; 

你需要定義你的path_to_website是什麼:

即:在/ var/WWW/

  1. 開放終端

  2. 列表項

  3. cd進入你的www目錄的根目錄
  4. 型 'PWD',不管它導致
  5. 輸入到$ host_path
+0

大聲笑:))你真的覺得我沒有填滿嗎?:) – heron 2013-03-22 19:57:55

+0

2013/03/22 23:36:45 [暴擊] 14388#0:* 4 stat()「path_to_website」失敗(13:權限被拒絕),客戶端:127.0.0.1,服務器:website.local,請求:「GET/HTTP/1.1」,主機:「website.local」..它顯示path_to_website,而不是實際位置 – 2013-03-22 19:59:17

+0

我剛剛用這個替換了真正的路徑'path_to_website'的信心。就這樣。這是真正的路徑 – heron 2013-03-22 20:00:10

0

Nginx上的日誌文件從不說謊。如果它說這是一個「權限被拒絕」的錯誤,那麼它是。您需要

  • 確保該文件夾本身「path_to_website」是可讀的用戶WWW的數據(它是運行nginx的基礎上您的屏幕截圖的用戶)。試試這個方法之一是在終端運行此命令:

    sudo -u www-data ls path_to_website 
    

,看看權限被拒絕WWW的數據或只是

ls -la path_to_website 

研究這條道路的許可信息。

  • 您的「path_to_website」的父文件夾可能無法被用戶www-data訪問。例如,如果您的path_to_website是「/ var/www/mysite /」,那麼www-data可能無法讀取「/ var」或「/ var/www」。