nginx-http-concat 是淘宝开发的基于Nginx减少HTTP请求数量的扩展模块,主要是用于合并减少前端用户Request的HTTP请求的数量
第一步下载
nginx-http-concat
git clone git://github.com/alibaba/nginx-http-concat.git
第二步 移动目录
mv nginx–http–concat /usr/local/src/nginx–http–concat
第三步
进入lnmp 下载目录
cd /home/lnmp1.3-full 我的下载解压目录为/home/www/lnmp1.3-full
第四步
编辑 lnmp.conf
vim lnmp.conf
添加
Nginx_Modules_Options='--add-module=/home/software/nginx-http-concat '
保存后退出
最后一步
./upgrade.sh nginx
一直到编译完成
这时就可以去配置 nginx/conf/vhost 下面的域名.conf 文件了
location /assets/
{
concat on;
concat_max_files 20;
}
编译成功后还要注意合并js时的400 Bad Request错误
由于Nginx在新版本中,使用了标准的 MIME-Type:application/javascript。而在nginx_concat_module模块目前版本的代码中,写的是 application/x-javascript 的类型
修改 nginx-http-concat/ngx_http_concat_module.c
把 x-javascript 改为 javascript
重新编译nginx即可
第二步 移动目录
mv nginx–http–concat /usr/local/src/nginx–http–concat
第三步
进入lnmp 下载目录
cd /home/lnmp1.3-full 我的下载解压目录为/home/www/lnmp1.3-full
第四步
编辑 lnmp.conf
vim lnmp.conf
添加
Nginx_Modules_Options='--add-module=/home/software/nginx-http-concat '
保存后退出
最后一步
./upgrade.sh nginx
一直到编译完成
这时就可以去配置 nginx/conf/vhost 下面的域名.conf 文件了
location /assets/
{
concat on;
concat_max_files 20;
}
编译成功后还要注意合并js时的400 Bad Request错误
由于Nginx在新版本中,使用了标准的 MIME-Type:application/javascript。而在nginx_concat_module模块目前版本的代码中,写的是 application/x-javascript 的类型
修改 nginx-http-concat/ngx_http_concat_module.c
把 x-javascript 改为 javascript
重新编译nginx即可