2016-05-14 136 views
0

我的服務器大致有此樹狀:nginx的服務403錯誤

www 
|-index.php 
|foo 
    |-index.php 
    |-bar.php 

我可以訪問/index.php,但訪問到//foo或其他任何導致403我已經試過各種配置,但他們都沒有工作。

nginx.conf文件:

worker_processes 1; 

events { 
    worker_connections 1024; 
} 

http { 
    include  mime.types; 

    default_type application/octet-stream; 

    sendfile  on; 

    keepalive_timeout 65; 

    gzip on; 
    gzip_disable "msie6"; 
    gzip_vary on; 
    gzip_proxied any; 
    gzip_comp_level 6; 
    gzip_buffers 16 8k; 
    gzip_http_version 1.1; 
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 

    server { 
     listen   80; 
     server_name localhost; 
     root /var/www/html; 

     location/{ 
      root  /var/www/html; 
      #try_files $uri /index.php$is_args$args; 
     } 

     location ~ \.php$ { 

      fastcgi_pass web_fpm:9000; 
      fastcgi_index index.php                            
      fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
    } 
} 

如果我取消了註釋行,任何請求提供的index.php,所以一點也不好。

回答

0

我找到了解決方案:設置索引。這裏是摘錄:

server { 
    listen   80; 
    server_name localhost; 
    root /var/www/html; 
    autoindex on; 

    location/{ 
     index index.php index.html; 
    } 

    location ~ \.php$ { 
     fastcgi_pass web_fpm:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 
     include  fastcgi_params; 
    } 
}