2013-07-06 94 views
1

我遇到一個403 Forbidden錯誤在我的筆記本電腦與Debian的7nginx的403在Debian下禁止7

文件權限是775權限:chmod 775 -R /無功/網絡

Nginx的錯誤日誌顯示:

2013/07/05 16:27:06 [error] 7351#0:* 12目錄索引 「/ var/www/install /」被禁止,客戶端:127.0.0.1,服務器: localhost,請求:「GET/install/HTTP/1.1」,主機:「localhost」

的phpinfo工作正常

特此我的配置:

1,/etc/nginx/nginx.conf

用戶WWW的數據;

worker_processes 1;

pid /var/run/nginx.pid;

事件worker_connections 768; #multi_accept on; }

HTTP {

## 
# Basic Settings 
## 

sendfile on; 
tcp_nopush on; 
tcp_nodelay on; 
keepalive_timeout 65; 
types_hash_max_size 2048; 
# server_tokens off; 

# server_names_hash_bucket_size 64; 
# server_name_in_redirect off; 

include /etc/nginx/mime.types; 
default_type application/octet-stream; 

## 
# Logging Settings 
## 

access_log /var/log/nginx/access.log; 
error_log /var/log/nginx/error.log; 
include /etc/nginx/conf.d/*.conf; 
include /etc/nginx/sites-enabled/*; } 

2,在/ etc/nginx的/啓用的站點 - /默認

服務器{ 聽80; ##監聽ipv4;這條線是默認和隱含的 #listen [::]:80 default_server ipv6only = on; ##偵聽的IPv6

#root /usr/share/nginx/www; 
root /var/www; 
index index.html index.php; 

# Make site accessible from http://localhost/ 
server_name localhost; 
server_name_in_redirect off; 

location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     # try_files $uri $uri/ /index.html; 
     try_files $uri $uri/ /index.php?$args; 
     # Uncomment to enable naxsi on this location 
     # include /etc/nginx/naxsi.rules 
} 

location /doc/ { 
     alias /usr/share/doc/; 
     autoindex on; 
     allow 127.0.0.1; 
     allow ::1; 
     deny all; 
} 

# Rewrite for Fork CMS 

位置〜^ /(後端|安裝|??API(/ \ d \ d)(/客戶))*。PHP $ { #後端/安裝/ API是現有的dirs,但都應該通過前面的try_files $ uri $ uri//index.php?args; }

location〜^(。+。php)(。*)$ {include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; }

# gzip 

gzip on;
gzip_disable「MSIE [1-6]。(?!。* SV1)」; #禁用不支持它的瀏覽器的gzip壓縮(在這種情況下,MS 版本6 SV1之前的Internet Explorer)。 gzip_http_version 1.1; gzip_vary on; #設置響應頭Vary:Accept-Encoding。 一些代理服務器存在一個錯誤,因爲它們會將壓縮內容提供給不支持它的 瀏覽器。通過設置Vary:Accept-Encoding標頭,您可以指示代理存儲壓縮版本和內容的未壓縮版本。gzip_comp_level 6; gzip_proxied 任何; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml + rss text/javascript application/javascript text/x-js; gzip_buffers 16 8k;

# client caching location ~ \.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ 
{ expires 31d; add_header Pragma "public"; add_header Cache-Control 
"public, must-revalidate, proxy-revalidate"; } 

# End of Fork 

回答

1

你的問題是,http://localhost/install經過的try_files這是$uri/所以它試圖訪問install作爲一個文件夾,但你沒有上autoindex,所以它不能用禁止的第二個規則錯誤。

try_files $uri $uri/ /index.php?$args; 

我建議刪除$uri/部分。

try_files $uri /index.php?$args; 
+0

Thanks @ Mohammad-AbuShady,它的工作原理。正如你所說我沒有'autoindex',所以我試圖''autoindex on;'在'try_files $ uri $ uri//index.php?$ args;'之前失敗。 – jazzi

0

我在一個VPS上設置了運行在nginx上的WordPress,並不斷得到一個403禁止的錯誤。權限的所有設置正確,一切似乎都很正常,但仍然一直得到403

出於某種原因,每個人都使用該行建議:

try_files $uri $uri/ /index.php?$args; 

當我照MAShady上述建議,並取消了$uri/,所以它看起來像這樣在我的服務器塊:

try_files $uri /index.php?$args; 

...而令人驚訝的是,配置工作!

真是太神奇了!

非常感謝!

+1

請嘗試閱讀本文http://stackoverflow.com/about,以獲得更多關於SO的問題和解答。你的貢獻沒有回答這個問題。這更多的是一個評論,你可以添加一次,你會增加你的聲譽:http://stackoverflow.com/faq#reputation –