1 nginx 安裝 可以參考:Nginx(openresty) 通過lua結合Web前端 實現圖片,文件,視頻等靜態資源 訪問權限驗證,進行鑒權 ,提高安全性-CSDN博客
2? 開啟目錄瀏覽
location /file{alias /data/www/; #指定目錄所在路徑autoindex on; #開啟目錄瀏覽autoindex_format html; #以html風格將目錄展示在瀏覽器中autoindex_exact_size off; #切換為 off 后,以友好的方式顯示文件大小,單位為 KB、MB 或者 GBautoindex_localtime on; #以服務器的文件時間作為顯示的時間charset utf-8,gbk; #顯示中文文件名}
3 查看
?
4?目錄瀏覽美化,采用第三方插件ngx-fancyindex
#下載,解壓ngx-fancyindex
wget https://github.com/aperezdc/ngx-fancyindex/releases/download/v0.5.2/ngx-fancyindex-0.5.2.tar.xz
tar xvf ngx-fancyindex-0.5.2.tar.xz
5 nginx 重新編譯
#編譯
./configure --prefix=/usr/local/openresty --user=www --group=www --with-http_gzip_static_module --with-threads --with-http_ssl_module --with-http_image_filter_module --with-debug --with-http_stub_status_module --with-openssl=../openssl-1.0.2j --with-http_v2_module --with-stream --add-module=../ngx-fancyindex-0.5.2
make
#備份和升級
mv /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/nginx/sbin/nginx_0530
cp ./build/nginx-1.1.9/objs/nginx /usr/local/openresty/nginx/sbin/
?6?下載Nginx-Fancyindex-Theme主題
主題下載
#下載,解壓
ll /usr/local/openresty/nginx/html/Nginx-Fancyindex-Theme-light/
total 216
-rw-r--r-- 1 root root 1088 Jan 12 2021 addNginxFancyIndexForm.js
-rw-r--r-- 1 root root 688 Jan 12 2021 fancyindex.conf
-rw-r--r-- 1 root root 1982 Jan 12 2021 footer.html
-rw-r--r-- 1 root root 707 Jan 12 2021 header.html
-rw-r--r-- 1 root root 114 Jan 12 2021 HEADER.md
-rw-r--r-- 1 root root 83667 Jan 12 2021 jquery.min.js
-rw-r--r-- 1 root root 117 Jan 12 2021 README.md
-rw-r--r-- 1 root root 99095 Jan 12 2021 showdown.min.js
-rw-r--r-- 1 root root 4417 Jan 12 2021 styles.css
7 nginx 配置修改
location /file
{include /usr/local/openresty/nginx/html/Nginx-Fancyindex-Theme-light/fancyindex.conf;alias /data/logs/online/log/; #指定目錄所在路徑charset utf-8,gbk; #顯示中文文件名
}
#效果如下?