Nginx开启目录浏览功能_2018_lcf

Nginx开启目录浏览功能

如果要开启目录浏览功能,请看下面操作:

1、开启全站所有目录浏览功能

vi  /usr/local/nginx/conf/nginx.conf   #编辑配置文件,在http {下面添加以下内容,在server{}外面:


autoindex on;   #开启nginx目录浏览功能

autoindex_exact_size off;   #文件大小从KB开始显示

autoindex_localtime on;   #显示文件修改时间为服务器本地时间

server {
....
}

:wq!  #保存,退出

2、只打开网站部分目录浏览功能

vi  /usr/local/nginx/conf/nginx.conf   #编辑配置文件,在server {下面添加以下内容:

--指定目录开启
 server {
    listen 8088;
    server_name 192.168.0.210;
    root /usr/local/nginx/html;

    location   /soft {

        autoindex on;

        autoindex_exact_size off;

        autoindex_localtime on;
    }
  }

---根目录下开启
 server {
    listen 8088;
    server_name 192.168.0.210;
    root /usr/local/nginx/html;

    location   / {

        autoindex on;

        autoindex_exact_size off;

        autoindex_localtime on;
    }
  }

:wq!  #保存,退出

service nginx reload   #重新加载nginx配置

至此,Nginx开启目录浏览功能教程完成!

猜你喜欢

转载自blog.csdn.net/cbuy888/article/details/82664962
今日推荐