利用nginx+fancyindex美化目录索引

利用nginx+fancyindex美化目录索引

1.下载第三方插件

1)下载插件
[root@localhost ~]# wget -O fancyindex.zip https://github.com/aperezdc/ngx-fancyindex/archive/v0.4.3.zip
[root@localhost ~]# wget -O fancytheme.zip https://github.com/Naereen/Nginx-Fancyindex-Theme/archive/master.zip

2)解压
[root@localhost ~]# unzip fancyindex.zip
[root@localhost ~]# unzip fancytheme.zip

2.重新编译nginx

[root@localhost ~]# tar -zxvf nginx-1.16.0.tar.gz
[root@localhost ~]# cd nginx-1.16.0
[root@localhost ~]# ./configure --prefix=/data1/nginx --add-module=/root/ngx-fancyindex-0.4.3/ --user=root --group=nginx

3.准备目录索引路径

[root@localhost ~]# mkdir /data1/www/html/repo/{centos6.5,centos7.5,tomcat,fio,redis,elasticsearch,abase} -p

4.编写站点配置文件

[root@localhost ~]# cd /data1/nginx/conf/conf.d/
[root@localhost conf.d]# vim repo.conf
server {
	listen 888;
	server_name localhost;

	location / {
		fancyindex on;
		fancyindex_localtime on;
		fancyindex_exact_size off;
		fancyindex_footer "/Nginx-Fancyindex-Theme-	dark/footer.html";
		fancyindex_header "/Nginx-Fancyindex-Theme-dark/header.html";
		root /data1/www/html;
		charset utf-8,gbk;
	}
}

5.将fancyindex放到站点目录

[root@localhost ~]# mv /root/Nginx-Fancyindex-Theme-master/fancyindex.conf /data1/nginx/conf/
[root@localhost ~]# mv /root/Nginx-Fancyindex-Theme-master/Nginx-Fancyindex-Theme-dark/ /data1/www/html/

将站点标题改成自己的称谓
[root@localhost ~]# vim /Nginx-Fancyindex-Theme-dark/header.html
修改最后一行即可

jiangxl_20200714

6.启动nginx

[root@localhost ~]# nginx -t
[root@localhost ~]# nginx

7.访问

访问http://192.1.44.123:888/repo
利用nginx+fancyindex美化目录索引_第1张图片

你可能感兴趣的:(Nginx)