nginx css,js合并插件,淘宝nginx合并js,css插件
先下载Nginx_concat_module,下载后把它放在/usr/local/src/文件夹中,新建文件夹nginx-http-concat把下载的config ngx_http_concat_module.c放到其中,到时候nginx需要指定该目录
查看nginx之前的配置
/usr/local/nginx/nginx -V nginx version: nginx/1.2.8 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) TLS SNI support enabled configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.21 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1c
开始安装,在上面的配置中添加 --add-module=/usr/local/src/nginx-http-concat 这段
cd /usr/local/src/nginx-1.2.8 ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.21 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1c --add-module=/usr/local/src/nginx-http-concat
然后make一下,不要 make install
先备份下,在copy刚刚编译过的nginx到安装目录,在检测下配置
mv /usr/local/nginx/nginx /usr/local/nginx/nginx_bak
把刚刚编译过的文件copy过去
cp -a ./objs/nginx /usr/local/nginx/nginx
检测配置
/usr/local/nginx/nginx -t -c /usr/local/nginx/conf/nginx.conf
在nginx host配置中增加
location / {
concat on;
expires 12h;
}