码迷,mamicode.com
首页 > 其他好文 > 详细

编译安装Tengine

时间:2019-06-03 09:36:11      阅读:703      评论:0      收藏:0      [点我收藏+]

标签:nload   gcc   tengine   localhost   ber   配置   目录   dso   基础   

Tengine

Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。

Tengine编译安装

Tengine的编译安装选项基本完全兼容于nginx,可以直接使用nginx编译时的安装选项对其进行编译安装,其具体的特性需要查阅官网http://tengine.taobao.org
1.获取tengine源码包

[root@localhost ~]# wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz

2.解压源码包

[root@localhost ~]# tar -xf tengine-2.3.0.tar.gz 

3.检查安装所需要环境和工具

[root@localhost tengine-2.2.3]# ./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/echo-nginx-module

4.生成模块并复制到相应的目录下

[root@localhost tengine-2.2.3]# make && make install

ngx_http_concat_module

该模块类似于apache中的mod_concat模块,用于合并多个文件在一个响应报文中。
请求参数需要用两个问号(‘??‘)例如:

http://example.com/??style1.css,style2.css,foo/style3.css

参数中某位置只包含一个‘?’,则‘?‘后表示文件的版本,例如:

http://example.com/??style1.css,style2.css,foo/style3.css?v=102234
location /static/css/ {
    concat on;
    concat_max_files 20;
}

location /static/js/ {
    concat on;
    concat_max_files 30;
}

指令

concat on | off
默认: concat off
上下文: http, server, location

在配置的地方使模块有效(失效)

concat_types MIME types
默认: concat_types: text/css application/x-javascript
上下文: http, server, location

定义哪些MIME types是可以被接受

concat_unique on | off
默认: concat_unique on
上下文: http, server, location

定义是否只接受在[MIME types]中的相同类型的文件,例如:

http://example.com/static/??foo.css,bar/foobaz.js

如果配置为 ‘concat_unique on‘ 那么将返回400,如果配置为‘concat_unique off‘
那么将合并两个文件。

concat_max_files number
默认: concat_max_files 10
上下文: http, server, location

定义最大能接受的文件数量。

concat_delimiter string
默认: 无
上下文 ‘http, server, location‘

定义在文件之间添加分隔符,例如

http://example.com/??1.js,2.js;

如果配置为concat_delimiter "\n"响应会在1.js和2.js两个文件之间插入一个换行符(‘\n‘);

concat_ignore_file_error ‘on | off‘
默认 ‘concat_ignore_file_error off‘
上下文 ‘http, server, location‘

定义模块是否忽略文件不存在(404)或者没有权限(403)错误

动态模块和静态模块的安装

静态模块编译安装

由于在编译时没有将concat模块编译进tengine所以需要将tengine重新进行编译
在编译时加上--with-http-concat_module

[root@localhost tengine-2.2.3]# ./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/echo-nginx-module --with-http_concat_module

然后执行make和make install

[root@localhost tengine-2.2.3]# make && make install

安装完成后查看所编译安装的选项

[root@localhost tengine-2.2.3]# /usr/local/tengine/sbin/nginx -V
Tengine version: Tengine/2.2.3 (nginx/1.8.1)
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/echo-nginx-module --with-http_concat_module

动态模块编译安装

动态编译是将模块单独编译然后再配置文件中导入此模块
1.先编译此模块再最后使用--with-http_concat_module=shared参数

[root@localhost tengine-2.2.3]# ./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/echo-nginx-module --with-http_concat_module=shared

2.对模块进行编译

[root@localhost tengine-2.2.3]# make dso_install

3.此时modules目录下已经有此模块

[root@localhost tengine-2.2.3]# ls /usr/local/tengine/modules/
ngx_http_concat_module.so

4.在配置文件中导入模块

dso {
    load ngx_http_concat_module.so;
}

编译安装Tengine

标签:nload   gcc   tengine   localhost   ber   配置   目录   dso   基础   

原文地址:https://blog.51cto.com/11886307/2403930

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!