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