在Nginx安装Fancyindex模块,让目录映射更加美观

在Nginx安装Fancyindex模块,让目录映射更加美观

请在在centos已经部署了nginx服务的前提下操作

  1. 下载ngx-fancyindex

    我提供的链接:下载链接,下完后记得解压出来是一个ngx-fancyindex-0.5.2.tar.xz的压缩文件,当然你也可以去github上下载。

  2. 上传文件

    ngx-fancyindex-0.5.2.tar.xz传到CentOS的/usr/local/nginx/html/ 路径下,然后解压

    unzip ngx-fancyindex-0.5.2.tar.xz
    

    没有unzip命令,请使用命令:yum install -y unzip zip安装

  3. 配置

    停止nginx服务

    ./usr/local/nginx/sbin/nginx stop
    

    进入nginx解压后的目录(注意不是安装目录)

    cd /root/nginx-1.26.1
    

    执行以下代码进行配置

    ./configure --prefix=/usr/local/nginx \
    		   --with-http_stub_status_module \
                --with-http_ssl_module \
                --add-module=/usr/local/nginx/html/ngx-fancyindex
    

    配置nginx.conf

    server {
        # 监听端口
        listen  8000;
    	charset utf-8;
        location / {
            # 存储资源文件的目录,根据自己的需求配置
            root /home/resource;
            fancyindex on;
            fancyindex_localtime on;
            fancyindex_exact_size off;
            sendfile on;
        }
    }
    

    重启nginx

    ./usr/local/nginx/sbin/nginx
    

    ok,不出意外,你就可以在浏览器访问你的资源了

posted @ 2024-06-25 23:34  勤匠  阅读(5)  评论(0编辑  收藏  举报