全球主机交流论坛
标题:
阿里系装B份子们,哥把Tengine改回NGINX
[打印本页]
作者:
Captain
时间:
2011-12-15 17:28
标题:
阿里系装B份子们,哥把Tengine改回NGINX
d
首先,马云坑到了很多钱。。。所以确实有一批大神在为他干活
其次,现在阿里系出来又是出书又是演讲跳大神装B。。不是牛人。。给我的感觉。。跳梁小丑一样,给后端的牛人抹黑,我实在看不习惯
第三,最近关于Tengine的讨论很火,简单看了下,在大流量下确实表现不错,而且据说可以过滤掉一些攻击或类似攻击流量,这是其宣称的特性,也是我们要保留的。
最后,加上了substitutions和nginx-accesskey这两个模块,前一个可用在垃圾站建设、过滤网页非法信息上,后一个可以做防盗链,非常适合个人站长用。
下面来说改动和安装过程,以centos 6 x64为基础环境演示, 在/root/soft下载文件和修改文件、编译安装
mkdir /root/soft
cd /root/soft
首先安装依赖包:
yum -y --noplugins install wget zip
yum -y --noplugins install unzip
yum -y --noplugins install gcc
yum -y --noplugins install make
yum -y --noplugins install pcre-devel
yum -y --noplugins install openssl-devel
yum -y --noplugins install gcc-c++
yum -y --noplugins install curl-devel
yum install -y -y subversion (SVN,从GG CODE下载substitutions 源码要用)
其次下载所需要的安装文件
下载Tengine
wget -c
http://tengine.taobao.org/download/tengine-1.2.0.tar.gz
下载Nginx-accesskey
wget -c
http://wiki.nginx.org/images/5/51/Nginx-accesskey-2.0.3.tar.gz
下载substitutions
svn checkout
http://substitutions4nginx.googlecode.com/svn/trunk/
substitutions4nginx-read-only
然后解压tengine和nginx-access
tar zxvf tengine-1.2.0.tar.gz
tar zxvf Nginx-accesskey-2.0.3.tar.gz
解压后,进入tengine目录
cd tengine
root@localhost tengine]# pwd
/root/soft/cloud/tengine
[root@localhost tengine]#
开始编辑nginx.h,nginx版本号和tengine的版本号都放在这个文件里
vi src/core/nginx./*
* Copyright (C) Igor Sysoev
*/
#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_
#define nginx_version 1000010
#define NGINX_VERSION "1.0.10" /* NGINX的版本号,最好别更改,更改了的话一会要改 substitutions的源码,我这里是改了的,所以等下我去改substitutions /*
#define NGINX_VER "nginx/" NGINX_VERSION
/*
#define tengine_version 1002001
#define TENGINE_VERSION "1.2.1"
#define TENGINE_VER "Tengine/" TENGINE_VERSION
这里是tengine的版本号了。。我选择全部注释掉*/
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
#endif /* _NGINX_H_INCLUDED_ */h
复制代码
保存后继续修改src/http/ngx_http_special_response.c 这个子程序在响应用户的http请求的时候,会反馈tengine的信息。。所以要
vi src/http/ngx_http_special_response.c
static u_char ngx_http_server_info_tail[] =
"</td>" CRLF
"</tr>" CRLF
"</table>" CRLF
;
static u_char ngx_http_error_full_tail[] =
"<hr/>Powered by " TENGINE_VER CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
"<hr/>Powered by Tengine" CRLF
"</body>" CRLF
"</html>" CRLF
复制代码
把里面的“TENGINE_VER CRLF”改成"NGINX_VER CRLF" 和"Powered by Tengine" 改成"Powered by NGINX"或者其他任意你想改的
再来看
src/http/ngx_http_header_filter_module.c这个文件
vi src/http/ngx_http_header_filter_module.c
static char ngx_http_server_string[] = "Server: Tengine" CRLF;
static char ngx_http_server_full_string[] = "Server: " TENGINE_VER CRLF;
复制代码
这个大家还是知道怎么改的吧。。。Server:随便你自己定义什么了。。。TENGINE_VER 还是改会NGINX_VER吧
改到这里之后。。。
TENGINE是改完了。。。其实。。直接用sed批量就可以改了。。。不过自从上次我用sed因为正则写错发生悲剧后(所有/etc/*.conf的文件都里面的空格都给我给去掉了。。。)所以这次我还是很低调的一个个改。。。而且要改的文件不多。
到这里了,如果您之前没有改nginx的版本号的话,那么你可以直接按照如下操作编译安装了。
./configure --prefix=/usr/local/cloud --user=cloud --group=cloud --with-poll_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_concat_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_sysguard_module --with-http_stub_status_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-backtrace_module --add-module=../../substitutions4nginx-read-only --add-module=../../nginx-accesskey-2.0.3
make&&make install
运行完毕后nginx安装在/usr/local/cloud下
然后添加NGINX运行的用户和用户组
groupadd cloud
useradd -d /dev/null -s /sbin/nologin -g cloud cloud
然后chown -R cloud:cloud /usr/local/cloud
再直接启动nginx
/usr/local/cloud/nginx
这里不附送nginx 服务启动脚本。。
如果您在上面的nginx.h改了nginx版本的话,那么你还需要更改/root/soft/substitutions4nginx-read-only/ngx_http_subs_filter_module.c这个文件,里面有判断nginx版本的代码
vi /root/soft/substitutions4nginx-read-only/ngx_http_subs_filter_module.c
从1264行
#if defined(nginx_version) && nginx_version >= 8025
ngx_regex_compile_t rc;
rc.pattern = pair->match;
rc.pool = cf->pool;
rc.err = err;
rc.options = options;
if (ngx_regex_compile(&rc) != NGX_OK) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err);
return NGX_ERROR;
}
pair->match_regex = rc.regex;
#else
pair->match_regex = ngx_regex_compile(&pair->match,
options, cf->pool, &err);
#endif
复制代码
把if else endif注释掉
注释后如下
/* #if defined(nginx_version) && nginx_version >= 8025 */
ngx_regex_compile_t rc;
rc.pattern = pair->match;
rc.pool = cf->pool;
rc.err = err;
rc.options = options;
if (ngx_regex_compile(&rc) != NGX_OK) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err);
return NGX_ERROR;
}
pair->match_regex = rc.regex;
/*#else
pair->match_regex = ngx_regex_compile(&pair->match,
options, cf->pool, &err);
#endif */
复制代码
保存后回到编译安装即可。。。。
到此结束。。。
作者:
qxwo
时间:
2011-12-15 17:42
什么意思?
作者:
minkdog.com
时间:
2011-12-15 18:19
不用
作者:
cicilee
时间:
2011-12-15 19:32
不知所云,仍觉很屌
作者:
manhere
时间:
2011-12-15 23:09
楼主牛叉,膜拜
作者:
一手好湿
时间:
2011-12-15 23:13
技术贴
作者:
Captain
时间:
2011-12-16 01:30
自己顶自己
作者:
张姑娘
时间:
2011-12-16 05:18
不关我是 lnmp一键包小白鲁国
作者:
格格男
时间:
2011-12-16 09:00
提示:
作者被禁止或删除 内容自动屏蔽
作者:
半成年
时间:
2011-12-16 13:06
提示:
作者被禁止或删除 内容自动屏蔽
作者:
zyzit
时间:
2011-12-16 13:44
技术啊
作者:
副站长
时间:
2011-12-16 14:13
写这么多不就是修改了版本号吗?
作者:
PPS
时间:
2011-12-16 17:26
原帖由
副站长
于 2011-12-16 14:13 发表
写这么多不就是修改了版本号吗?
貌似好像是这样哦
作者:
Captain
时间:
2011-12-16 19:42
原帖由
PPS
于 2011-12-16 17:26 发表
貌似好像是这样哦
是把被改掉的版本号改回来。。。。
作者:
zzyxz
时间:
2011-12-17 01:31
技术贴
作者:
shy9000
时间:
2012-1-21 22:56
src/core/nginx.c 225行记得修改
原文似乎落掉了ngx_write_stderr("Tengine version: " TENGINE_VER " (" NGINX_VER ")"
欢迎光临 全球主机交流论坛 (https://loc.516000.xyz/)
Powered by Discuz! X3.4