默认nginx不支持自动列表,因此需要开启目录列表功能才能让目录内的文件按照我的需求自动罗列出来方便获取当中的文件;
我开启了nginx多站点,按照此笔记配置《Centos 6配置安装Nginx多站点方法》
nginx.conf配置路径为:
/etc/nginx/nginx.conf
/usr/local/nginx/conf/nginx.conf
配置如下:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/vhosts/*.conf;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
第32-34行是我添加上去的代码
autoindex on;//自动显示目录
autoindex_exact_size off;//人性化方式显示文件大小否则以byte显示
autoindex_localtime on;//按服务器时间显示,否则以gmt时间显示
配置Nginx目录列表的方法详细参照:http://wiki.nginx.org/NginxChsHttpAutoindexModule
更新完nginx.conf配置文件后一定要重启nginx服务器才能让其生效
/etc/init.d/nginx restart
此时刷新绑定域名或者IP对应目录下的文件就呈现出来了
转载请注明:楚盟网 » Nginx开启目录列表功能