tengine安装
环境
CentOS6.6 X86_64
下载
当前2015-11-26 tengine最新版为 Tengine-2.1.1.tar.gz
wget http://tengine.taobao.org/download/tengine-2.1.1.tar.gz
安装
tar -xf tengine-2.1.1.tar.gz
cd tengine-2.1.1
默认安装在/usr/local/nginx下,可以自己修改
./configure --prefix=/usr/local/nginx
确保配置没有问题,再进行编译
make
make install
(如果不是root用户执行,请使用sudo make install)
如果./configure,经常出现的错误及解决方法
./configure: error: the HTTP rewrite module requires the PCRE library.
yum install -y pcre pcre-devel
./configure: error: SSL modules require the OpenSSL library.
yum install -y openssl-devel
常用命令
进入安装目录的sbin目录下
cd /usr/local/nginx/sbin
启动服务
./nginx
启动完成后,测试
curl http://localhost/ 查看输出,会看到Thank you for using tengine.服务启动成功
也可以用浏览器打开 http://ip/
停止服务
./nginx -s quit
重新加载配置
./nginx -s reload
nginx服务器版本和模块
./nginx -m
查看帮助
./nginx -h
配置文件
配置文件位于安装目录的conf文件夹下 nginx.conf
隐藏nginx服务器版本
在http配置块中,增加 server_tokens off;
例如:
http {
……省略配置
server_tokens off; ->即可隐藏版本号
…….省略配置
}
测试curl -I http://localhost/
修改前
HTTP/1.1 200 OK
Server: Tengine/2.1.1
Date: Thu, 26 Nov 2015 10:07:22 GMT
Content-Type: text/html
Content-Length: 555
Last-Modified: Thu, 26 Nov 2015 09:44:29 GMT
Connection: keep-alive
ETag: "5656d47d-22b"
Accept-Ranges: bytes
修改后
HTTP/1.1 200 OK
Server: Tengine
Date: Thu, 26 Nov 2015 10:08:36 GMT
Content-Type: text/html
Content-Length: 555
Last-Modified: Thu, 26 Nov 2015 09:44:29 GMT
Connection: keep-alive
ETag: "5656d47d-22b"
Accept-Ranges: bytes
混淆nginx服务器版本
修改源代码,把nginx版本任意修改
进入源代码目录
cd tengine-2.1.1/src/core
vim nginx.h ,修改12-16行中的nginx和tengine名称及版本
12 #define nginx_version 1006002
13 #define NGINX_VERSION "1.6.2"
14 #define NGINX_VER "nginx/" NGINX_VERSION
15
16 #define TENGINE "Tengine"
17 #define tengine_version 2001000
18 #define TENGINE_VERSION "2.1.1"
19 #define TENGINE_VER TENGINE "/" TENGINE_VERSION
示例
12 #define nginx_version 5001009
13 #define NGINX_VERSION "5.1.9"
14 #define NGINX_VER "aws/" NGINX_VERSION
15
16 #define TENGINE "Taws"
17 #define tengine_version 3003003
18 #define TENGINE_VERSION "3.3.3"
19 #define TENGINE_VER TENGINE "/" TENGINE_VERSION
20
21 #define NGINX_VAR "NGINX"
22 #define NGX_OLDPID_EXT ".oldbin"
修改完成后,重新编译安装
测试查看效果
[root@vtfsdb1 sbin]# curl -I http://localhost/
HTTP/1.1 200 OK
Server: Taws/3.3.3
Date: Thu, 26 Nov 2015 10:19:37 GMT
Content-Type: text/html
Content-Length: 555
Last-Modified: Thu, 26 Nov 2015 10:19:23 GMT
Connection: keep-alive
ETag: "5656dcab-22b"
Accept-Ranges: bytes
[root@vtfsdb1 sbin]# ./nginx -m
Tengine version: Taws/3.3.3 (aws/5.1.9)
loaded modules:
ngx_core_module (static)
ngx_errlog_module (static)
ngx_conf_module (static)
ngx_dso_module (static)
ngx_syslog_module (static)
ngx_events_module (static)
ngx_event_core_module (static)
...
修改端口
根据实际情况修改
listen 8080;
说明
所有相关的目录,链接,参数等请根据实际情况自行调整。