Nginx添加第三方模块ngx-fancyindex
操作系统:CentOS release 6.10
Web中间件:nginx/1.14.0
Nginx是一款轻量级的Web 服务器。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。
任务背景:Nginx Web 服务器自带的目录浏览功能看起来并不美观,在这里使用ngx-fancyindex插件来美化目录浏览功能。
即配置Nginx索引(目录浏览),美化索引页面。
实战任务:下载ngx-fancyindex插件并配置
要求:
1.已经安装好nginx的环境下安装配置ngx-fancyindex插件;
2.nginx同插件一同安装配置。
一、已经安装好nginx的环境下安装配置ngx-fancyindex插件;
操作步骤:
1.下载插件
https://github.com/aperezdc/ngx-fancyindex/archive/master.zip
https://github.com/aperezdc/ngx-fancyindex/releases #选择相关版本下载
2.解压缩
[root@sky9890 src]# unzip ngx-fancyindex-master.zip
3.编辑及配置
[root@sky9890 nginx-1.14.0]#
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_image_filter_module \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--add-module=../ngx-fancyindex-master #添加第三方插件,指定解压的目录
[root@sky9890 nginx-1.14.0]#make
[root@sky9890 nginx-1.14.0]killall nginx
[root@sky9890 nginx-1.14.0]# cp /objs/nginx /usr/local/nginx/sbin/ #复制重新编译的nginx文件到nginx原来安装目录下
[root@sky9890 nginx-1.14.0]nginx
[root@sky9890 conf]# vi nginx.conf
......
location /{
root /usr/local/nginx/html/
fancyindex on; #开启索引
fancyindex_exact_size off; #显示文件大小
fancyindex_localtime on; #使用本地时间
fancyindex_footer footer.html; #把当前路径下的footer.html内容作为底部
fancyindex_header header.html; #把当前路径下的header.html内容作为顶部
fancyindex_ignore footer.html header.html;
}
运行效果图如下:
二、未安装好nginx的环境下安装配置ngx-fancyindex插件;
[root@sky9890 nginx-1.14.0]#
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_image_filter_module \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--add-module=../ngx-fancyindex-master #添加第三方插件,指定解压的目录
[root@sky9890 nginx-1.14.0]#make
[root@sky9890 nginx-1.14.0]#make install
[root@sky9890 conf]# vi nginx.conf #配置 nginx即可
......
location /{
root /usr/local/nginx/html/
fancyindex on; #开启索引
fancyindex_exact_size off; #显示文件大小
fancyindex_localtime on; #使用本地时间
fancyindex_footer footer.html; #把当前路径下的footer.html内容作为底部
fancyindex_header header.html; #把当前路径下的header.html内容作为顶部
fancyindex_ignore footer.html header.html;
}
实战经验:
常见错误1:
nginx: [emerg] getpwnam("nginx") failed in /usr/local/nginx/conf/nginx.conf:1
#useradd nginx #添加nginx用户
#vi nginx.conf #配置nginx用户
常见错误2:
[root@sky9890 conf]# nginx
nginx: [emerg] open() "/application/nginx/logs/www.access.log" failed (2: No such file or directory) #没有此路径
access_log /usr/local/nginx/logs/www.access.log; #修改本地路径
error_log /usr/local/nginx/logs/www.error.log; #修改本地路径
常见错误3:
[root@sky9890 conf]# nginx -s reload
nginx: [emerg] unknown directive "fancyindex" in /usr/local/nginx/conf/nginx.conf:61 #没有下载配置fancyindex插件
- Nginx的第三方模块ngx-fancyindex安装
- Nginx添加ngx-fancyindex模块的方法
- 使用 NgxFancyIndex 代替nginx原有的autoindex模块美化文件显示
- centos6.5生产环境编译安装nginx-1.11.3并增加第三方模块ngx_cache_purge、nginx_upstream_check、ngx_devel_kit、lua-nginx
- Windows 下 Nginx 添加 ngx_http_sub_module 模块
- nginx添加第三方模块
- Nginx 编译,添加未编译安装模块ngx_cache_purge
- nginx(tengine)第三方模块 :ngx_cache_purge
- nginx添加第三方模块,以及启用nginx本身支持的模块
- Nginx 编译,添加未编译安装模块ngx_cache_purge
- 解读nginx第三方模块ngx_http_auth_request_module
- nginx 用户访问添加密码;autoindex模块详解;传送client IP
- 为nginx添加ngx_lua模块并进行安装测试
- nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下)
- Yum/RPM安装的Nginx如何添加第三方模块(LuaJIT)
- nginx第三方模块(ngx_http_auth_pam_module)加注释
- nginx添加第三方模块,以及启用nginx本身支持的模块
- 已安装的nginx添加第三方模块
- nginx 平滑添加第三方模块
- Nginx:一致性哈希(第三方模块ngx_http_consistent_hash)