Go
Go
文章目录
  1. 首先我们从下载地址获取到tengine的安装包
  2. 开始安装Tengine,之前需要安装必要的软件包gcc, gcc-c++, pcre-devel, openssl-devel等
  3. 进入到Tengine的根目录运行,显示少了文件目录则重新创建
  4. 安装完成,可以通过网页80端口进行访问,也可修改conf/nginx.conf文件修改Tengine的配置
  5. 做个链接
  6. 添加服务
  7. 贴一下配置文件

Tengine编译安装

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

把Tengine编译安装在CentOS服务器上

首先我们从下载地址获取到tengine的安装包

1
wget https://tengine.taobao.org/download/tengine-2.3.3.tar.gz # change version

开始安装Tengine,之前需要安装必要的软件包gcc, gcc-c++, pcre-devel, openssl-devel

1
2
mkdir -p /usr/local/nginx # custom root library
tar -zxvf tengine-2.3.3.tar.gz && cd tengine-2.3.3 # tar and goto
1
2
3
4
5
./configure \
> --prefix=/usr/local/nginx/
> --conf-path=/etc/nginx/nginx.conf \
> --with-http_v2_module
... # edit oll property and module
1
make && make install

进入到Tengine的根目录运行,显示少了文件目录则重新创建

1
2
cd /usr/local/nginx
./sbin/nginx

安装完成,可以通过网页80端口进行访问,也可修改conf/nginx.conf文件修改Tengine的配置

curl -i localhost

image-20210630175145955

做个链接

1
ln -s /usr/local/nginx/sbin/nginx /bin/nginx

添加服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// nginx.service
[Unit]
Description=Nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
#User=nobody
ExecStart=/usr/bin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/bin/nginx -s reload
ExecStop=/usr/bin/nginx -s stop

[Install]
WantedBy=multi-user.target

贴一下配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
user  root;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 65535;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";

#pid logs/nginx.pid;


events {
use epoll;
worker_connections 65535;
#multi_accept on;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;
#access_log "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=1G" main;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;
tcp_nodelay on;
client_header_buffer_size 4k;
open_file_cache max=102400 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
client_header_timeout 15;
client_body_timeout 15;
reset_timedout_connection on;
send_timeout 15;
server_tokens off;
client_max_body_size 1g;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 32k;
#gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_proxied any;

# ssl
ssl_certificate cert.crt;
ssl_certificate_key cert.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_session_tickets on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;

resolver 114.114.114.114;


server {
listen 80;
server_name www.ijava.me s.ijava.me;
return 301 https://$host$request_uri;
}

server {
listen 80 default;
listen 443 ssl http2 default;
rewrite ^(.*) https://www.ijava.me;
}

server {
listen 443 ssl http2;
server_name s.ijava.me;
charset utf-8;
location / {
root /root/data/static;
autoindex on;
autoindex_exact_size on;
autoindex_format html;
autoindex_localtime on;
set $limit_rate 1M;
}
}

server {
listen 443 ssl http2;
server_name www.ijava.me;

ssl_certificate ijava_me.crt;
ssl_certificate_key ijava_me.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_session_tickets on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers on;
#ssl_stapling on;
#ssl_stapling_verify on;

location / {
root html;
index index.html index.htm;
charset utf-8;
}

location /status {
stub_status on;
}
}

}