Tengine的模块编译安装方式
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.开启Tengine多文件合并功能失败
1>.编译安装Tengine-2.1.2
博主阅读: https://www.cnblogs.com/yinzhengjie/p/12081823.html
2>.修改配置文件
[[email protected] ~]# cat /yinzhengjie/softwares/nginx/conf.d/node101_yinzhengjie_org.cn.conf server { listen 80; listen 443 ssl; server_name node101.yinzhengjie.org.cn; access_log /yinzhengjie/softwares/nginx/logs/node101_yinzhengjie_org_cn_access.log my_access_json; error_log /yinzhengjie/softwares/nginx/logs/node101_yinzhengjie_org_cn_error.log; location / { root /yinzhengjie/data/web/nginx/static/cn; index index.html; #开启多文件合并功能 concat on; #定义有效的请求referer,用空格隔开即可 valid_referers none blocked server_names *.baidu.com example.* ~\.google\.; #如果没有在上面的有效链接定义那么均属于无效请求referer if ($invalid_referer) { return 403; } #如果是一些常见的压测试工具,咱们直接进给他拒绝访问 if ($http_user_agent ~ "ApacheBench|WebBench|TurnitinBot|Sougou web spider|Grid Server"){ return 403; } } location = /favicon.ico { root /yinzhengjie/data/web/nginx/images/jd; } } [[email protected] ~]# [[email protected] ~]# /yinzhengjie/softwares/tengine-2.1.2/sbin/nginx -t #注意看提示,Tengine说不支持 nginx: [emerg] unknown directive "concat" in /yinzhengjie/softwares/nginx/conf.d/node101_yinzhengjie_org.cn.conf:14 configuration file /yinzhengjie/softwares/tengine-2.1.2/conf/nginx.conf test failed [[email protected] ~]# [[email protected] ~]#
3>.查看Tengine的版本,观察是否有"ngx_http_concat_module"相关的模块
[[email protected] ~]# /yinzhengjie/softwares/tengine-2.1.2/sbin/nginx -V #从编译参数来看,编译安装时压根就没有编译Tengine相关模块 Tengine version: Tengine/2.1.2 (nginx/1.6.2) built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) TLS SNI support enabled configure arguments: --prefix=/yinzhengjie/softwares/tengine-2.1.2 --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=/usr/local/src/echo-nginx-module
nginx: [emerg] unknown directive "concat" in /yinzhengjie/softwares/nginx/conf.d/node101_yinzhengjie_org.cn.conf:14 [[email protected] ~]#
4>.对比Nginx和Tengeine是否支持多文件合并
[[email protected] /usr/local/src]# ll total 5860 drwxr-xr-x 6 root root 186 Dec 23 22:35 echo-nginx-module drwxr-xr-x 9 1001 1001 186 Dec 22 08:19 nginx-1.14.2 -rw-r--r-- 1 root root 1015384 Dec 4 2018 nginx-1.14.2.tar.gz drwxr-xr-x 13 50469 users 4096 Dec 26 06:52 tengine-2.1.2 -rw-r--r-- 1 root root 2137295 Sep 5 16:58 tengine-2.1.2.tar.gz drwxrwxr-x 14 root root 4096 Dec 24 21:11 tengine-2.3.2 -rw-r--r-- 1 root root 2835884 Sep 5 16:58 tengine-2.3.2.tar.gz [[email protected] /usr/local/src]# [[email protected] /usr/local/src]# cd tengine-2.3.2/ [[email protected] /usr/local/src/tengine-2.3.2]# [[email protected] /usr/local/src/tengine-2.3.2]# [[email protected] /usr/local/src/tengine-2.3.2]# ./configure --help | grep concat #我们发现2019年8月20号发布的Tengine版本并没有直接支持ngx_http_concat_module。。 [[email protected] /usr/local/src/tengine-2.3.2]# [[email protected] /usr/local/src/tengine-2.3.2]# cd ../tengine-2.1.2/ [[email protected] /usr/local/src/tengine-2.1.2]# [[email protected] /usr/local/src/tengine-2.1.2]# ./configure --help | grep concat #我们发现2015年12月31日发布最新的稳定版本是支持"多文件合并"功能的。 --with-http_concat_module enable ngx_http_concat_module --with-http_concat_module=shared enable ngx_http_concat_module (shared) [[email protected] /usr/local/src/tengine-2.1.2]# [[email protected] /usr/local/src/tengine-2.1.2]# cd ../nginx-1.14.2/ [[email protected] /usr/local/src/nginx-1.14.2]# [[email protected] /usr/local/src/nginx-1.14.2]# ./configure --help | grep concat #很显然,多文件合并是是Tengine独有的功能,Nginx并不支持。 [[email protected] /usr/local/src/nginx-1.14.2]#
5>.Tengine支持动态加载模块
[[email protected] /usr/local/src/tengine-2.1.2]# ./configure --help | grep concat --with-http_concat_module enable ngx_http_concat_module --with-http_concat_module=shared enable ngx_http_concat_module (shared) [[email protected] /usr/local/src/tengine-2.1.2]# 温馨提示: --with-http_concat_module: 这个是Tengine的静态模块 --with-http_concat_module=shared 这个就是Tengine的动态模块
动态加载模块描述: 这个模块主要是用来运行时动态加载模块,而不用每次都要重新编译Tengine. 如果你想要编译官方模块为动态模块,你需要在configure的时候加上类似这样的指令(--with-http_xxx_module),./configure --help可以看到更多的细节. 如果只想要安装官方模块为动态模块(不安装Nginx),那么就只需要configure之后,执行 make dso_install命令. 动态加载模块的个数限制为128个. 如果已经加载的动态模块有修改,那么必须重起Tengine才会生效. 只支持HTTP模块. 模块 在Linux/FreeeBSD/MacOS下测试成功.
博主推荐阅读:
http://tengine.taobao.org/document_cn/dso_cn.html
二.
三.