1 修改配置文件
vim /usr/local/nginx/conf/nginx.conf
#找到location
添加autoindex on;
# 修改前
location / {
root html;
index index.html index.htm;
}
# 修改后
location / {
root html;
index index.html index.htm;
autoindex on;
}
# 或者新增一个虚拟路径(建议这样做)
location /xiaopeng{
alias /tmp;
autoindex on;
# index index.html index.htm;
}
2 重载nginx配置
cd /usr/local/nginx/conf #进入nginx目录
./nginx -s reload # 重载服务即可