我遇到一个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