检查旧nginx配置参数
[root@localhost nginx]$ cd /usr/local/nginx/sbin
[root@localhost sbin]$ ./nginx -V
nginx version: nginx/1.19.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
configure arguments:
上传新的nginx,解压缩
[root@localhost software]$ tar -zvxf nginx-1.22.0.tar.gz
编译新的nginx
[root@localhost nginx-1.22.0]$ ./configure --prefix=/usr/local/nginx --with-http_ssl_module
[root@localhost nginx-1.22.0]$ make
备份旧版本的nginx可执行文件,复制新版本的nginx执行文件
[root@localhost sbin]# mv nginx nginx20220803.old
[root@localhost sbin]# ls
nginx20220803.old nginx.old
[root@localhost nginx-1.22.0]$ cp objs/nginx /usr/local/nginx/sbin/
因对系统响应实时度不高,故先关旧nginx,再重启nginx,不要求平滑升级
[root@localhost nginx-1.22.0]# ps -ef|grep nginx
root 20139 27781 0 14:57 ? 00:00:00 nginx: worker process
root 20200 20165 0 14:57 pts/1 00:00:00 grep --color=auto nginx
root 27781 1 0 2020 ? 00:00:00 nginx: master process ./nginx
[root@localhost nginx-1.22.0]# kill -9 27781
[root@localhost nginx]$ cd /usr/local/nginx/sbin
[root@localhost sbin]$ ./nginx
查看nginx版本已经升级到新版
[root@localhost sbin]$ ./nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module