1.下载相关的依赖包解压
wget -c http: //www .zlib.net /zlib-1 .2.12. tar .gz
wget -c https: //www .openssl.org /source/openssl-1 .1.1q. tar .gz
wget -c https: //nchc .dl.sourceforge.net /project/pcre/pcre/8 .45 /pcre-8 .45. tar .gz
tar xf zlib-1.2.12. tar .gz -C /opt
tar xf openssl-1.1.1q. tar .gz -C /opt
tar xf pcre-8.45. tar .gz -C /opt
|
2.下载openresty1.21.4源码包解压
wget -c https: //openresty .org /download/openresty-1 .21.4.1. tar .gz
tar xf openresty-1.21.4.1. tar .gz
#修改文件夹名称为openresty-1.22.0
mv openresty-1.21.4.1 openresty-1.22.0
#删除nginx-1.21.4.1
rm -rf openresty-1.22.0 /bundle/nginx-1 .21.4
|
3.下载nginx1.22.0源码包,复制到openresty-1.22.0/bundle下
wget -c http: //nginx .org /download/nginx-1 .22.0. tar .gz
tar xf nginx-1.22.0. tar .gz -C openresty-1.22.0 /bundle/
|
4.修改nginx1.22.0中的nginx.h为openresty(路径为openresty-1.22.0/bundle/nginx-1.22.0/src/core,如不是请自行修改)
修改nginx.h
sudo sed -i '/nginx\//s?nginx/?openresty/?g' openresty-1.22.0 /bundle/nginx-1 .22.0 /src/core/nginx .h
cp index.html 50x.html openresty-1.22.0 /bundle/nginx-1 .22.0 /html
|
5.修改 openresty-1.22.0/bundle/nginx-no_pool.patch 把版本替换为1.22.0
sed -i /nginx-1 .21.4/ 's?nginx-1.21.4?nginx-1.22.0?g' openresty-1.22.0 /bundle/nginx-no_pool .patch
sed -i 's?1021004?1022000?g' openresty-1.22.0 /bundle/nginx-no_pool .patch
|
6.编译openresty
cd openresty-1.22.0
. /configure \
--prefix= /usr/share/openresty \
--with-zlib= /opt/zlib-1 .2.12 \
--with-pcre= /opt/pcre-8 .45 \
--with-openssl= /opt/openssl-1 .1.1q \
--with-pcre-jit \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-http_v2_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_secure_link_module \
--with-http_random_index_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-threads \
--with-http_ssl_module
make && make install
|
7.添加服务文件
cat >openresty.service <<EOF
# Stop dance for OpenResty
# =========================
#
# ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=The OpenResty Application Platform
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile= /usr/share/openresty/nginx/logs/nginx .pid
ExecStartPre= /usr/share/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart= /usr/share/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload= /usr/share/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=- /sbin/start-stop-daemon --quiet --stop --retry QUIT /5 --pidfile /usr/share/openresty/nginx/logs/nginx .pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
|
8.打包文件
tar zcvf openresty-1.22.0. tar .gz /usr/share/openresty openresty.service
|
9.在其他主机上安装
#上传tar包
tar xf openresty-1.22.0. tar .gz -C /
mv openresty.service /lib/systemd/system
systemctl unmask openresty.service
systemctl daemon-reload
systemctl enable --now openresty
|
wget --no-check-certificate --http-user=sh_sdn --http-password=1234@Sdn1234 http://192.168.1.1:56366/openresty-1.22.0.tar.gz #!/binbash mkdir /home/sdn/bak cp /usr/local/openresty/nginx/conf/nginx.conf /home/sdn/bak/ cp -r /usr/local/openresty/nginx/sites-enabled /home/sdn/bak/ apt remove openresty -y --allow-unauthenticated tar -xf /tmp/openresty-1.22.0.tar.gz -C / cp /home/sdn/bak/nginx.conf /usr/share/openresty/nginx/conf/ cp -r /home/sdn/bak/sites-enabled /usr/share/openresty/nginx/ mv /openresty.service /lib/systemd/system/ chown root:root /lib/systemd/system/openresty.service chmod 755 /lib/systemd/system/openresty.service chmod -R 755 /usr/share/openresty chown -R root:root /usr/share/openresty rm /usr/bin/openresty ln -f /usr/share/openresty/bin/openresty /usr/bin/openresty sed -i 's#/usr/local/openresty/nginx/sites-enabled/#/usr/share/openresty/nginx/sites-enabled/#g' /usr/share/openresty/nginx/conf/nginx.conf systemctl unmask openresty.service systemctl daemon-reload systemctl enable --now openresty systemctl restart openresty openresty -V
标签:http,tar,--,升级,nginx,openresty,1.22 From: https://www.cnblogs.com/hanwei666/p/18099468