安装配置nginx加载concat模块

centos7.2 x86_64

阿里开源的concat模块,用于减少网站访问中js和css的请求,以减轻服务器压力;该技术即将css、js等静态资源合并为一个或几个资源,配合缓存可大大节省网络传输时间,加快网页加载速度。

1,安装concat模块需编译安装nginx:
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel pcre pcre-devel git
mkdir -p /var/web/
useradd web
mkdir -p /var/web/
chown web.web /var/web/
cd /var/web/
git clone https://github.com/alibaba/nginx-http-concat.git
wget http://nginx.org/download/nginx-1.12.1.tar.gz
tar zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure --prefix=/var/web/nginx --sbin-path=/usr/sbin/nginx --user=web --group=web --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/var/web/nginx-http-concat
make
make install

2,concat模块使用方法:

#该段代码意味着网站根目录下/static/目录里的css和js才可以合并
    location /static/ {
        concat on;
        concat_max_files 20;
        concat_unique off;
        concat_types text/css text/html application/javascript;
    }

https://localhost/static/??/pc/style/loading.min.css,pc/js/aboutus.min.js,global/js/stats.js
该链接能看到对应js和css的内容即为配置concat成功可用
 

转载于:https://my.oschina.net/u/2404183/blog/1546981

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值