https://blog.csdn.net/weixin_42689212/article/details/119121188
1、查看nginx和OpenSSL版本
[root@host sbin]# ./nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
2、备份原 nginx 二进制文件,切换到nginx所在目录进行备份,备份的过程系统不受影响
mv nginx nginx-1.18 //在sbin目录下复制即可。
将压缩包上传到服务器进行解压,上传任意位置,没有要求。
tar xf nginx-1.20.1.tar.gz
切换到解压后的nginx文件夹内执行,只需要到 make,千万不要 make install 。如果make install 会将原来的配置文件覆盖
[root@host 下载]# cd nginx-1.20.1/
[root@hos nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module
[root@host nginx-1.20.1]# make
3、复制nginx-1.20.1下的nginx到原来的nginx目录下,注意nginx-1.20.1中nginx在objs目录下而不是在sbin下面
[root@host nginx-1.20.1]# cd objs/
[root@host objs]# cp nginx usr/local/nginx/sbin/
4、测试是否替换成功
[root@host sbin]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@host sbin]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled