tengine-lua-yunsou

570 人阅读
分类:
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/sh
#检测是否是root用户
if [[ $(id -u) != "0" ]]; then
    printf "\e[42m\e[31mError: You must be root to run this install script.\e[0m\n"
    exit 1
fi
 
#检测是否是CentOS 7或者RHEL 7
if [[ $(grep "release 7." /etc/redhat-release 2>/dev/null | wc -l) -eq 0 ]]; then
    printf "\e[42m\e[31mError: Your OS is NOT CentOS 7 or RHEL 7.\e[0m\n"
    printf "\e[42m\e[31mThis install script is ONLY for CentOS 7 and RHEL 7.\e[0m\n"
    exit 1
fi
clear
 
#检测程序下载存放的目录
softflie="/home/nginx"
if [ ! -d $softflie ]; then
    printf "\e[42m\e[41m 创建:/home/nginx 目录\e[0m\n"
    mkdir $softflie
fi
 
#前期安装准备
Ready_install(){
#创建运行nginx 账号
groupadd -g 108 -r www && useradd -s /sbin/nologin -u 108 -r -g www www
#配置安装编译时所需要的组件
sed -i "s/exclude=kernel*/#exclude=kernel*/g " /etc/yum.conf
yum -y install gcc gcc-c++  pcre pcre-devel zlib patch zlib-devel openssl openssl-devel gd-devel zlib libxslt zlib-devel libxslt-devel libunwind gperftools geoip geoip-devel  unzip lua-devel libmaxminddb-devel  libmaxminddb git
sed -i "s/#exclude=kernel*/exclude=kernel*/g " /etc/yum.conf
printf "\e[42m\e[41m Nginx组件已安装完全成 \e[0m\n"
 
#下载nginx 跟模块文件
nginxfile="/home/nginx/tengine-2.3.2.tar.gz"
if [ ! -e $nginxfile ];then
    printf "\e[42m\e[41m 正在下载tengine 程序包 \e[0m\n"
    wget -P /home/nginx https://tengine.taobao.org/download/tengine-2.3.2.tar.gz
fi
 
ngx_cache_file="/home/nginx/2.3.tar.gz"
if [ !  -e $ngx_cache_file ]; then
    printf "\e[42m\e[41m 正下截ngx_cache插件 \e[0m\n"
    wget -P /home/nginx https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
fi
 
pcre_file="/home/nginx/pcre-8.38.tar.gz"
if [ ! -e $pcre_file ]; then
    printf "\e[42m\e[41m 正下截pcre源码包 \e[0m\n"
    wget -P /home/nginx https://ftp.pcre.org/pub/pcre/pcre-8.38.tar.gz
fi
 
ngx_hmux="/home/nginx/v1.4.tar.gz"
if [ ! -e $ngx_hmux ]; then
    printf "\e[42m\e[41m 正在下载ngx_hmux插件 \e[0m\n"
    wget -P /home/nginx https://github.com/wangbin579/nginx-hmux-module/archive/v1.4.tar.gz
fi
 
ngx_headers="/home/nginx/v0.30.tar.gz"
if [ ! -e $ngx_headers ]; then
    printf "\e[42m\e[41m 正在下ngx_headers扩展 \e[0m\n"
    wget -P /home/nginx https://github.com/openresty/headers-more-nginx-module/archive/v0.30.tar.gz
fi
 
ngx_sh_logs="/home/nginx/cut_nginx_log.sh"
if [ ! -e $ngx_sh_logs ]; then
    printf "\e[42m\e[41m 下截日志管理脚本 \e[0m\n"
    wget -P /home/nginx/ https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/cut_nginx_log.sh
fi
 
 
ngx_fair_file="/home/nginx/3.3.tar.gz"
if [ ! -e $ngx_fair_file ]; then
    printf "\e[42m\e[41m 开始下载ngx_upstream_fair \e[0m\n"
    wget -P /home/nginx https://github.com/leev/ngx_http_geoip2_module/archive/3.3.tar.gz 
fi
 
ngx_nginx_file="/home/nginx/nginx.conf-bak"
if [ ! -e $ngx_nginx_file ]; then
    printf "\e[42m\e[41m 开始下载conf \e[0m\n"
    wget -P /home/nginx https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/tengine_2.3/Config/nginx.conf-bak
fi
 
ngx_vts_file="/home/nginx/v0.1.18.tar.gz"
if [ ! -e $ngx_vts_file ]; then
    printf "\e[42m\e[41m 开始下载vts插件 \e[0m\n"
    wget -P /home/nginx https://github.com/vozlt/nginx-module-vts/archive/v0.1.18.tar.gz
fi
 
ngx_GeoIP_City_file="/home/nginx/GeoLite2-City.mmdb"
if [ ! -e  $ngx_GeoIP_City_file ]; then
    printf "\e[42m\e[41m 开始下载geoip-city \e[0m\n"
    wget -P /home/nginx https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/tengine_2.3/GeoIP/GeoLite2-City.mmdb
fi
 
ngx_GeoIP_Country_file="/home/nginx/GeoLite2-Country.mmdb"
if [ ! -e  $ngx_GeoIP_Country_file ]; then
    printf "\e[42m\e[41m 开始下载geoip-country \e[0m\n"
    wget -P /home/nginx   https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/tengine_2.3/GeoIP/GeoLite2-Country.mmdb
fi
 
ngx_conf_proxy_file="/home/nginx/proxy.conf"
if [ ! -e  $ngx_conf_proxy_file ]; then
    printf "\e[42m\e[41m 开始下载conf \e[0m\n"
    wget -P /home/nginx   https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/tengine_2.3/Config/proxy.conf
fi
 
ngx_conf_top_file="/home/nginx/top.conf"
if [ ! -e $ngx_conf_top_file   ]; then
    printf "\e[42m\e[41m 开始下载conf \e[0m\n"
    wget -P /home/nginx   https://top-software-file.oss-cn-hongkong.aliyuncs.com/Nginx/tengine_2.3/Config/top.conf
fi
 
ngx_LuaJIT_file="/home/nginx/LuaJIT-2.1.0-beta3.tar.gz"
if [ ! -e $ngx_LuaJIT_file  ]; then
    printf "\e[42m\e[41m 开始下载LuaJIT \e[0m\n"
    wget -P /home/nginx http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
fi
 
ngx_devel_kit_file_module="/home/nginx/v0.3.1.tar.gz"
if [ ! -e $ngx_devel_kit_file_module ]; then
    printf "\e[42m\e[41m 开始下载LuaJIT \e[0m\n"
    wget -P /home/nginx  https://github.com/vision5/ngx_devel_kit/archive/v0.3.1.tar.gz
fi
 
ngx_luamodule_file="/home/nginx/v0.10.10.tar.gz"
if [ ! -e $ngx_luamodule_file ]; then
    printf "\e[42m\e\[41m 开始下载lua nginx 模块 \e[0m\n"
    wget -P /home/nginx https://github.com/openresty/lua-nginx-module/archive/v0.10.10.tar.gz
fi
 
ngx_yunsuo_module_file="/home/nginx/nginx-plugin-master.zip"
if [ ! -e $ngx_yunsuo_module_file ]; then
   printf "\e[42m\e\[41m 开始下载云锁 nginx 模块 \e[0m\n"
   wget  https://codeload.github.com/yunsuo-open/nginx-plugin/zip/master -O nginx-plugin-master.zip
   mv nginx-plugin-master.zip /home/nginx
fi
 
}
#lua 插件安装
lua_install(){
tar xf /home/nginx/LuaJIT-2.1.0-beta3.tar.gz -C /usr/share/
cd /usr/share/LuaJIT-2.1.0-beta3/
make PREFIX=/usr/local/luajit
make install PREFIX=/usr/local/luajit
 
echo '
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1' >> /etc/profile
source /etc/profile
}
 
#开始安装
start_install(){
lua_install
#解压Nginx 包
tar xvf /home/nginx/2.3.tar.gz -C /home/nginx 
tar xvf /home/nginx/pcre-8.38.tar.gz -C /home/nginx 
tar xvf /home/nginx/tengine-2.3.2.tar.gz -C /home/nginx
tar xvf /home/nginx/v0.4.5.tar.gz -C /home/nginx/ 
tar xvf /home/nginx/v1.4.tar.gz -C /home/nginx/
tar xvf /home/nginx/v0.30.tar.gz -C /home/nginx/
tar xvf /home/nginx/3.3.tar.gz -C /home/nginx/ 
tar xf /home/nginx/v0.1.18.tar.gz -C /home/nginx/ 
tar xf /home/nginx/v0.3.1.tar.gz -C /home/nginx/
tar xf /home/nginx/v0.10.10.tar.gz -C /home/nginx
unzip -d /home/nginx/ /home/nginx/nginx-plugin-master.zip
 
 
#创建LOG 日志目录
mkdir -p /home/logs/nginx/
 
#开始编译安装
cd /home/nginx/tengine-2.3.2
./configure --prefix=/usr/local/nginx \
 --user=www   --group=www  \
 --sbin-path=/usr/sbin/nginx  \
 --conf-path=/usr/local/nginx/config/nginx.conf  \
 --error-log-path=/home/logs/nginx/error.log  \
 --http-log-path=/home/logs/nginx/www_logs/web_access.log  \
 --pid-path=/run/nginx.pid  \
 --lock-path=/usr/local/nginx/lock/nginx.lock  \
 --with-pcre-opt=-fPIC \
 --with-pcre-jit --with-ld-opt='-ljemalloc' --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" \
 --with-http_v2_module --with-http_sub_module \
 --with-http_gunzip_module  \
 --with-http_realip_module --with-http_flv_module  \
 --with-http_stub_status_module \
 --with-http_gzip_static_module  \
 --with-http_secure_link_module \
 --with-http_degradation_module \
 --with-http_image_filter_module \
 --with-http_ssl_module \
 --with-http_geoip_module \
 --http-proxy-temp-path=/usr/local/nginx/proxy_temp \
 --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp \
 --http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp \
 --http-scgi-temp-path=/usr/local/nginx/scgi_temp \
 --add-module=/home/nginx/ngx_cache_purge-2.3 \
 --add-module=/home/nginx/nginx-hmux-module-1.4 \
 --add-module=/home/nginx/headers-more-nginx-module-0.30 \
 --add-module=/home/nginx/ngx_http_geoip2_module-3.3 \
 --add-module=/home/nginx/nginx-module-vts-0.1.18 \
 --add-module=./modules/ngx_http_proxy_connect_module \
 --add-module=./modules/ngx_http_upstream_check_module \
 --add-module=./modules/ngx_http_upstream_session_sticky_module  \
 --add-module=./modules/ngx_http_upstream_dynamic_module \
 --add-module=./modules/ngx_http_user_agent_module \
 --add-module=./modules/ngx_http_concat_module \
 --add-module=./modules/ngx_http_footer_filter_module \
 --add-module=./modules/ngx_http_reqstat_module \
 --add-module=./modules/ngx_http_slice_module \
 --add-module=./modules/ngx_http_trim_filter_module \
 --add-module=./modules/ngx_http_upstream_consistent_hash_module \
 --add-module=./modules/ngx_multi_upstream_module \
 --add-module=/home/nginx/ngx_devel_kit-0.3.1 \
 --add-module=/home/nginx/lua-nginx-module-0.10.10 \
 --add-module=/home/nginx/nginx-plugin-master \
 --with-pcre=/home/nginx/pcre-8.38
 
  
make -j 2 && make install
  
echo "配置Logs日志"
mv /home/nginx/cut_nginx_log.sh /usr/local/nginx/config/
chmod +x /usr/local/nginx/config/cut_nginx_log.sh
echo  "59 23 * * * /bin/sh /usr/local/nginx/config/cut_nginx_log.sh " >> /tmp/crontab.sys
crontab /tmp/crontab.sys
systemctl restart crond
 
echo -e '[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target' > /lib/systemd/system/nginx.service
 
echo '
net.core.netdev_max_backlog = 32768
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.wmem_max = 16777216
net.ipv4.ip_local_port_range = 5000    65000
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1' >> /etc/sysctl.conf
sysctl -p
 
echo '
* soft nofile 1024000
 
* hard nofile 1024000
 
hive   - nofile 1024000
 
hive   - nproc  1024000' >> /etc/security/limits.conf 
 
mkdir -p /usr/local/nginx/proxy_temp/
chmod 777 -R /usr/local/nginx/proxy_temp/
mkdir -p /usr/local/nginx/proxy_temp/tempcache
mkdir -p /usr/local/nginx/proxy_temp/homecache
mkdir -p /usr/local/nginx/fastcgi_temp/cgitempcache
mkdir -p /usr/local/nginx/fastcgi_temp/cgiwpcache
mkdir -p /usr/local/nginx/config/conf.d/
mkdir -p /usr/local/nginx/GeoIP/
\cp -rf /home/nginx/GeoLite2-City.mmdb  /usr/local/nginx/GeoIP/
\cp -rf /home/nginx/GeoLite2-Country.mmdb  /usr/local/nginx/GeoIP/
\cp -rf /home/nginx/proxy.conf    /usr/local/nginx/config/conf.d/
\cp -rf /home/nginx/top.conf /usr/local/nginx/config/conf.d/
\cp -rf /home/nginx/nginx.conf-bak  /usr/local/nginx/config/
systemctl daemon-reload
systemctl start nginx
systemctl enable nginx
cd /mnt/
wget https://download.yunsuo.com.cn/v3/yunsuo_agent_64bit.tar.gz && tar xvzf yunsuo_agent_64bit.tar.gz && chmod +x yunsuo_install/install && yunsuo_install/install
netstat -anpt | grep 80
printf "\e[42m\e\ 登录云锁账号使用的命令如下: \e[0m\n"
printf "\e[42m\e\ /usr/local/yunsuo_agent/agent_smart_tool.sh -u cloud_name -p cloud_passwd \e[0m\n"
}
 
Ready_install
start_install


和博主交个朋友吧
关闭

博主小程序[微信扫一扫]

    发布篇幅
    • 文章总数:0
    • 原创:0
    • 转载:0
    • 译文:0
    文章分类
      文章存档
      阅读排行