zoukankan      html  css  js  c++  java
  • Nginx浏览目录配置及美化

    命令 默认值 值域 作用域 EG
    autoindex off on:开启目录浏览;off:关闭目录浏览 http, server, location autoindex on;打开目录浏览功能
    autoindex_format html html、xml、json、jsonp 分别用这几个风格展示目录 http, server, location autoindex_format html; 以网页的风格展示目录内容。该属性在1.7.9及以上适用
    autoindex_exact_size on on:展示文件字节数;off:以可读的方式显示文件大小 http, server, location autoindex_exact_size off; 以可读的方式显示文件大小,单位为 KB、MB 或者 GB,autoindex_format为html时有效
    autoindex_localtime off on、off:是否以服务器的文件时间作为显示的时间 http, server, location autoindex_localtime on; 以服务器的文件时间作为显示的时间,autoindex_format为html时有效

    完整配置如下:

    location /download
    {
        root /home/map/www/; #指定目录所在路径
        autoindex on; #开启目录浏览
        autoindex_format html; #以html风格将目录展示在浏览器中
        autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB
        autoindex_localtime on; #以服务器的文件时间作为显示的时间
        charset utf-8,gbk; #展示中文文件名
    }
    

    目录浏览美化

    ngx-fancyindex

    要查看Nginx编译了哪些模块,执行以下命令:

    2>&1 nginx -V | tr ' ' ' '|grep module

    查看完整的编译参数:nginx -V

    动态编译添加Nginx模块

    1. 在GitHub下载最新源码:ngx-fancyindex
    2. Nginx-Index源码下载下来后,解压,放到nginx源码目录(/usr/local/nginx)中,执行下面的代码,编译:
    3. nginx -V 参数添加 --add-module=ngx-fancyindex-0.4.2
    4. make 这里不要 make install!!
    5. 选择Fancy Index主题 Nginx-Fancyindex-Theme

    Fancy Index 配置

    1. 进入Nginx安装的web目录,执行nginx -V,输出configure arguments: --prefix=/usr/local/nginx,就是这个目录
    2. git clone https://github.com/lanffy/Nginx-Fancyindex-Theme.git
    3. 在nginx location模块中添加Fancy Index配置,如下:
    location /download
    {
        include /usr/local/nginx/html/Nginx-Fancyindex-Theme/fancyindex.conf; # 目录美化配置
        root /home/map/www/; #指定目录所在路径
        autoindex on; #开启目录浏览
        autoindex_format html; #以html风格将目录展示在浏览器中
        autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB
        autoindex_localtime on; #以服务器的文件时间作为显示的时间
        charset utf-8,gbk; #展示中文文件名
    }
    
    #fancyindex.conf
    fancyindex on;
    fancyindex_localtime on;
    fancyindex_exact_size off;
    fancyindex_header "/Nginx-Fancyindex-Theme/header.html";
    fancyindex_footer "/Nginx-Fancyindex-Theme/footer.html";
    
    # Ignored files will not show up in the directory listing, but will still be public.
    fancyindex_ignore "examplefile.html";
    
    # Making sure folder where files are don't show up in the listing.
    fancyindex_ignore "Nginx-Fancyindex-Theme";
    
    # Maximum file name length in bytes, change as you like.
    fancyindex_name_length 255;
    
  • 相关阅读:
    “铁大失物帮”Alpha版使用说明
    绩效评估
    改进方案评论
    意见汇总
    对其他团队项目的意见和建议
    冲刺周期
    属于我的专属博客团队地址
    第一个冲刺周期-第三天
    第一个冲刺周期-第二天
    动手动脑与动手
  • 原文地址:https://www.cnblogs.com/meilong/p/nginx-liu-lan-mu-lu-pei-zhi-ji-mei-hua.html
Copyright © 2011-2022 走看看