作者/来源:yixinu.com
栏目:运维/编程
日期:2013-06-06 19:38:31
1、源码编译:
--add-module=
/usr/local/src/nginx-http-concat-maste 添加模块
[root@hnlmserver nginx-1.2.1]# nginx -V nginx version: nginx/1.2.1 TLS SNI support enabled configure arguments: --user=nobody --group=nobody --prefix=/usr/local/nginx-1.2.1 --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/usr/local/src/nginx-http-concat-master
2、配置文件
server { listen 80; server_name localhost; location / { concat on; #启用concat函数 concat_unique off; #允许返回不同类型的文件内容(js,css同时合并) concat_delimiter " "; #自动在返回每个文件内容的末尾添加换行符 concat_ignore_file_error off; #不要忽略所合并的文件不存在等错误 root html/test; index index.html; } }
3、html代码
<html> <head> <link rel="stylesheet" type="text/css" href="??1.css,2.css" /> <title></title> </head> <body> <div class="a" ></div> <div class="b"></div> </body> </html>
根目录下的文件为:
[root@hnlmserver test]# ll 总用量 12 -rw-r--r--. 1 root root 59 6月 6 19:29 1.css -rw-r--r--. 1 root root 60 6月 6 19:30 2.css -rw-r--r--. 1 root root 177 6月 6 19:31 index.html