nginx目录浏览功能
【nginx目录浏览功能】
1.修改nginx.conf配置,这个功能是在虚拟主机里定义的
server {
listen 80;
server_name www.nginx_yy.com;
#让nginx虚拟主机支持中文解析
charset utf-8;
access_log logs/yy_access.log;
location / {
root /www/nginx_yy;
#关闭虚拟主机默认的首页功能
#index index.html index.htm;
#自动的展示root所定义的目录下所有内容,开启目录索引功能
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
2.还得检查虚拟主机目录下,不要有index.html文件
[root@backup nginx_yy]# pwd
/www/nginx_yy
[root@backup nginx_yy]# ll
total 44
-rw-r--r-- 1 root root 36347 Oct 24 2015 1.jpg
-rw-r--r-- 1 root root 30 Aug 2 00:44 haha.txt
-rw-r--r-- 1 root root 0 Aug 2 00:38 heihei.sh
-rw-r--r-- 1 root root 76 Aug 1 23:01 index.html.bak
3.用浏览器访问网页测试