nginx 1.16.1平滑升级至nginx 1.20.1

本文介绍了如何将Nginx 1.16版本升级到1.20版本,提供了两种方法:一是直接make upgrade,二是通过逐步停机替换二进制文件并重启。详细步骤包括备份配置、更改编译选项、执行升级和验证新版本。

原环境:

# /usr/sbin/nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.1.1c  28 May 2019
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_ssl_module --with-openssl=/usr/local/ssl --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --add-module=/opt/nginx/ngx_devel_kit-0.3.1 --add-module=/opt/nginx/lua-nginx-module-0.10.15 --add-module=/opt/nginx/nginx_upstream_check_module-master

# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

安装包下载:
http://nginx.org/download/nginx-1.20.1.tar.gz

安装nginx1.20.1过程:

cp /opt/nginx/conf/nginx.conf{,.bak}
tar -zxf nginx-1.20.1.tar.gz 
cd nginx-1.20.1
cp auto/lib/openssl/conf{,.bak}
vim auto/lib/openssl/conf 
:39,42s@/.openssl@@g修改去掉.openssl/
           # CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
           # CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
           # CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
           # CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
           # CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
改为:
            CORE_INCS="$CORE_INCS $OPENSSL/include"
            CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
            CORE_LIBS="$CORE_LIB
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值