1.确定你安装好lnmp  然后备份一下nginx

cd ~

service nginx stop

mv /usr/local/nginx  /usr/local/nginx18

2.安装Tengine  (备注with前两个-)

cd ~
wget http://tengine.taobao.org/download/tengine-2.0.0.tar.gz
tar zxvf tengine-2.0.0.tar.gz
cd tengine-2.0.0
./configure –with-http_concat_module

make
make install

3.把以前的配置文件拷贝回来

mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.confbak

cp /usr/local/nginx18/conf/nginx.conf /usr/local/nginx/conf/nginx.conf

4.编辑/usr/local/nginx/conf/nginx.conf     的对应的Server中添加如下内容

location /static/ {
concat on; #启用concat函数
concat_unique off; #允许返回不同类型的文件内容(js,css同时合并)
concat_delimiter “\n”; #自动在返回每个文件内容的末尾添加换行符
concat_ignore_file_error off; #不要忽略所合并的文件不存在等错误
}

5.重启Tengine

service nginx start

6.测试,你的js和css可以这样写

<link rel="stylesheet" type="text/css" href="/static/css/??style.css,css.css">
<script type="text/javascript" src="/static/js/??jquery.js,slide.js"></script>

Comments are closed.

Post Navigation