天天看點

nginx+fancyindex漂亮目錄浏覽帶搜尋功能更換原因系統環境安裝所需包并下載下傳nginx1.14.0和fancy插件編譯Nginx和fancy

nginx+fancyindex漂亮目錄浏覽帶搜尋功能

  • 更換原因
  • 系統環境
  • 安裝所需包并下載下傳nginx1.14.0和fancy插件
  • 編譯Nginx和fancy

更換原因

nginx自帶目錄索引,功能簡單、樣式也不好看,現在使用fancyindex插件來做索引,配上一個漂亮的主題還有搜尋的功能

系統環境

系統:CentOS Linux release 7.5.1804

web:Nginx 1.14.0

fancy: fancyindex V0.4.3

fancy-theme: fancy v1.1

安裝所需包并下載下傳nginx1.14.0和fancy插件

$ yum install gcc gcc-c++ wget ntpdate vim-enhanced autoconf automake openssl-devel pcre-devel unzip
$ wget http://nginx.org/download/nginx-1.14.0.tar.gz
$ wget -O fancyindex.zip https://github.com/aperezdc/ngx-fancyindex/archive/v0.4.3.zip
$ wget -O fancytheme.zip https://github.com/Naereen/Nginx-Fancyindex-Theme/archive/master.zip
$ tar -zxvf nginx-1.14.0.tar.gz
$ unzip fancyindex.zip
$ unzip fancytheme.zip
           

編譯Nginx和fancy

$ cd nginx-1.14.0
$ ./configure --prefix=/usr/local/nginx --add-module=../ngx-fancyindex-0.4.3/
//确定沒有錯誤後,執行make && make install
$ make && make install
$ ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
$ mv /root/Nginx-Fancyindex-Theme-master/fancyindex.conf /usr/local/nginx/conf/
$ mv /root/Nginx-Fancyindex-Theme-master/Nginx-Fancyindex-Theme-dark/ /usr/local/nginx/html/fancydark
$ vim /usr/local/nginx/conf/nginx.conf
           

nginx.conf配置檔案 把fancyindex.conf包含到location /中

worker_processes 1;

events {
worker_connections 1024;
}


http {


include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
 listen 80;
 server_name 192.168.244.131;

 location / {
 root html;
 include fancyindex.conf;
 }

 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 root html;
 }

 }

}
           

以上是nginx.conf 配置檔案

下面來看/usr/local/nginx/fancyindex.conf

fancyindex on;
fancyindex_localtime on;
fancyindex_exact_size off;
fancyindex_header "/fancydark/header.html";
fancyindex_footer "/fancydark/footer.html";
fancyindex_ignore "fancydark";
fancyindex_name_length 255;

           

以上是fancyindex.conf

下面讓我們來啟動nginx

$ rm -rf /usr/local/nginx/html/index.html
$ nginx
           
nginx+fancyindex漂亮目錄浏覽帶搜尋功能更換原因系統環境安裝所需包并下載下傳nginx1.14.0和fancy插件編譯Nginx和fancy

繼續閱讀