分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

Nginx资源合并优化模块nginx-http-concat

发布时间:2023-09-06 01:45责任编辑:白小东关键词:nginxhttp

此模块是nginx的第三方模块nginx-http-concat,此模块可以合并资源,节约带宽和节约请求响应时间

下载地址

git clone git://github.com/alibaba/nginx-http-concat.git

官网解释

https://github.com/alibaba/nginx-http-concat

首先将此模块编译进nginx里

/usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.13.9

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)

built with OpenSSL 1.0.1e-fips 11 Feb 2013

TLS SNI support enabled

configure arguments: --prefix=/usr/local/nginx --add-module=/root/nginx-1.13.9/nginx-http-concat --add-module=/root/nginx-1.13.9/naxsi-0.56rc1/naxsi_src --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-http_slice_module --with-mail --with-threads --with-file-aio --with-stream --with-mail_ssl_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-pcre --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module && make

将新编译的/objs/nginx里的 Nginx放到/usr/local/nginx/sbin里 把旧的nginx备份好

开始编辑conf 目录里的nginx.conf文件

在server字段里添加如下配置文件

location /css/ {
??????????concat on; ??#开启资源合并
??????????concat_max_files 20; #允许合并的最大资源数目
??????????concat_unique on; #允许合并不同类型资源
??????????concat_ignore_file_error on; #忽略404或403错误
???????}
???????location /js/ {
??????????concat on; ??#开启资源合并
??????????concat_max_files 20; #允许合并的最大资源数目
??????????concat_unique on; #允许合并不同类型资源
??????????concat_ignore_file_error on; #忽略404或403错误
???????}

编辑完成后检查配置文件 重启

/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

/usr/local/nginx/sbin/nginx -s reload

打开浏览器查看服务器页面响应速度,会有明显的提升。

至此nginx-http-concat模块编译配置完成

点一杯星巴克

Nginx资源合并优化模块nginx-http-concat

原文地址:https://www.cnblogs.com/qingyuanyuanxi/p/8559181.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved