安装配置nginx加载concat模块
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
centos7.2?x86_64
阿里開源的concat模塊,用于減少網(wǎng)站訪問中js和css的請(qǐng)求,以減輕服務(wù)器壓力;該技術(shù)即將css、js等靜態(tài)資源合并為一個(gè)或幾個(gè)資源,配合緩存可大大節(jié)省網(wǎng)絡(luò)傳輸時(shí)間,加快網(wǎng)頁加載速度。
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模塊使用方法:
#該段代碼意味著網(wǎng)站根目錄下/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
該鏈接能看到對(duì)應(yīng)js和css的內(nèi)容即為配置concat成功可用
?
轉(zhuǎn)載于:https://my.oschina.net/u/2404183/blog/1546981
總結(jié)
以上是生活随笔為你收集整理的安装配置nginx加载concat模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在Github上面搭建一个自己域名的He
- 下一篇: win下打包成tar.gz