nginx目錄列表及美化

1.安裝nginx

下載 http://nginx.org/download/nginx-1.12.2.tar.gzhtml

2.下載fancyindex

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

3.下載主題

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

4.編譯安裝

./configure --prefix=/usr/local/Cellar/nginx/1.12.2_1 
--with-http_ssl_module --with-pcre --sbin-path=/usr/local/Cellar/nginx/1.12.2_1/bin/nginx --with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl/include' --with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module --with-http_v2_module --add-module=../ngx-fancyindex    --with-http_addition_module
 
 make

全新安裝須要make install.nginx

已經安裝好nginx的不須要make install,到make中生成objs目錄中執行2>&1 ./nginx -V | tr ' ' '\n'|grep fan查看fancyindex是否配置成功.git

而後覆蓋原有的nginx便可.github

5.配置

  1. nginx配置
location /download{

            include /usr/local/Cellar/nginx/1.12.2_1/html/Nginx-Fancyindex-Theme/fancyindex.conf; # 目錄美化配置
            alias /Users/mac-desktop/video/; #指定目錄所在路徑
            autoindex on; #開啓目錄瀏覽
            autoindex_format html; #以html風格將目錄展現在瀏覽器中
            autoindex_exact_size off; #切換爲 off 後,以可讀的方式顯示文件大小,單位爲 KB、MB 或者 GB
            autoindex_localtime on; #以服務器的文件時間做爲顯示的時間
            charset utf-8,gbk; #展現中文文件名
            
        }
  1. 主題位置

將主題文件夾整個移動到nginx的html目錄中去.瀏覽器

6.截圖

驗證結果

相關文章
相關標籤/搜索