centos7.2默认安装好nginx后,会在/usr/share/nginx/html下作为主目录

但是如果想访问下面的目录会发现没有权限,返回403错误

这时候要注意在/etc/nginx/nginx.conf中配置一项即可,重启nginx后就能看到有目录了!

autoindex on;
server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            autoindex on;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

  

当然注意自己创建的目录权限需要755

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2021-10-14
  • 2021-10-22
  • 2021-08-11
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-11-26
  • 2021-12-20
  • 2022-01-22
相关资源
相似解决方案