`
MauerSu
  • 浏览: 494896 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

安装nginx-http-concat和nginx平滑升級

 
阅读更多
源:http://wytoy.iteye.com/blog/1506739
评:
  Nginx_concat_module 是淘宝开发的基于Nginx减少HTTP请求数量的扩展模块,主要是用于合并减少前端用户Request的HTTP请求的数量


    下载后把它放在/usr/local/src/文件夹中,到时候nginx需要指定该目录


    这个需要重新编译nginx,所以顺便把nginx升级了下。


下载最新版本




Linux代码  收藏代码

    wget http://nginx.org/download/nginx-1.0.15.tar.gz 

 

查看之前安装时怎么配置的,copy下红色代码,这里是下面要用到的


Linux代码  收藏代码

    /usr/local/nginx/sbin/nginx -V 
     
    TLS SNI support disabled 
    configure arguments: <strong>--</strong> 
    prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-proxy-temp-path=/var/nginx/proxy --http-fastcgi-temp-path=/var/nginx/fastcgi --http-client-body-temp-path=/var/nginx/client 

 

开始安装,在上面的配置中添加 --add-module=/usr/local/src/nginx-http-concat 这段


Linux代码  收藏代码

    tar zxvf nginx-1.0.15.tar.gz 
    cd nginx-1.0.15.tar.gz 
     
    ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-proxy-temp-path=/var/nginx/proxy --http-fastcgi-temp-path=/var/nginx/fastcgi --http-client-body-temp-path=/var/nginx/client --add-module=/usr/local/src/nginx-http-concat 




Linux代码  收藏代码

    make 

 

执行到这里就好了,千万不要 make install


为了防止意外发生啊,先备份先老版本


Linux代码  收藏代码

    mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old 

 

把刚刚编译过的文件copy过去


Linux代码  收藏代码

    cp -a nginx /usr/local/nginx/sbin/ 

 

检测一下 NGINX 是否正常。


Linux代码  收藏代码

    /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 

 

到这里升级nginx就可以了,如果要使用http-concat的话还需要修改nginx.conf文件,在里面添加下面代码




Linux代码  收藏代码

    location /js/ { 
        # 打开concat 功能 
        # 默认关闭 
        concat on; 
        # 允许concat最大的文件数(http://m114.org/test/??1.css,2.css,3.css...10.css) 默认最大设置十个文件。 
        # (默认: 10) 
        # concat_max_files 10; 
        # 只允许相同类型的文件(例:http://m114.org/test/??m114.css,m23.js 默认情况下是不允许的) 
        # 默认是开启的 
        # concat_unique on; 
        # 允许内容的类型 
        # (default: application/x-javascript, text/css) 
        # concat_types text/html; 
    }  



安装好了如何使用呢?


http://localhost/js/??a.js,b.js


两个问号(??),需要合并的文件(a.js,b.js)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics