下载美化模块

git clone https://github.com/aperezdc/ngx-fancyindex.git

下载美化皮肤

git clone https://github.com/Naereen/Nginx-Fancyindex-Theme.git

安装Nginx

宝塔面板在安装Nginx时必须要选择源码编译安装,这样在安装的时候可以加入美化模块
  • 模块名:ngx_fancyindex(只能使用下划线)
  • 模块路径:添加下载美化模块的完整路径,比如/tmp/ngx-fancyindex

配置网站开启目录浏览并使用美化模块

在禁止访问的下方添加配置项

注意Nginx-Fancyindex要放在网站的根路径下,比如网站的根目录是/www/wwwroot/ftp,那么Nginx-Fancyindex要放在/www/wwwroot/ftp
    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    # 开启目录浏览功能
    location / {
        fancyindex on; # 使用fancyindex
        fancyindex_exact_size off; # 不显示精确大小
        fancyindex_time_format "%Y-%m-%d %H:%M";# 文件日期
        fancyindex_localtime on;# 使用用户本地时间
        
        # 页面头
        fancyindex_header /Nginx-Fancyindex/header.html;
        
        # 页尾
        fancyindex_footer /Nginx-Fancyindex/footer.html;
        
        # 忽略的文件夹/文件
        #fancyindex_ignore "myStyle";
        #fancyindex_ignore "README.md";
    }