平滑升级
1、获取现有的程序编译的参数 -V
[root@localhost nginx-1.20.1]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.20.1
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
2、获取新版本的软件包或者功能包
将软件包移到服务器中
[root@localhost ~]# ls
echo-nginx-module-master.zip
[root@localhost ~]# unzip echo-nginx-module-master.zip
[root@localhost ~]# ls
echo-nginx-module-master echo-nginx-module-master.zip
3、将新功能或新版本进行编译
[root@localhost ~]# tar xf nginx-1.20.1.tar.gz 。
[root@localhost ~]# cd nginx-1.20.1/
[root@localhost nginx-1.20.1]# ./config --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=../echo-nginx-module-master
//新添加 --add-module=../echo-nginx-module-master
[root@localhost nginx-1.20.1]# make
编译安装完可以跟老版本进行对比
[root@localhost nginx-1.20.1]# ls objs/
addon Makefile nginx.8 ngx_auto_headers.h ngx_modules.o
autoconf.err nginx ngx_auto_config.h ngx_modules.c src
[root@localhost nginx-1.20.1]# ll objs/nginx /usr/local/nginx/sbin/nginx
-rwxr-xr-x. 1 root root 6831056 10月 27 15:56 objs/nginx
-rwxr-xr-x. 1 root root 6308640 10月 27 14:52 /usr/local/nginx/sbin/nginx
4、备份原程序
[root@localhost ~]# cp /usr/local/nginx/sbin/nginx /opt/
5、覆盖
[root@localhost nginx-1.20.1]# /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@localhost nginx-1.20.1]# objs/
addon/ nginx src/
[root@localhost nginx-1.20.1]# objs/nginx -s stop ;/usr/local/nginx/sbin/nginx
[root@localhost nginx-1.20.1]# ps -ef |grep nginx
root 289782 289781 0 15:41 pts/3 00:00:00 /usr/libexec/pk-command-not-found nginx -V
root 518199 1 0 16:26 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 518202 518199 0 16:26 ? 00:00:00 nginx: worker process
nginx 518203 518199 0 16:26 ? 00:00:00 nginx: worker process
nginx 518204 518199 0 16:26 ? 00:00:00 nginx: worker process
nginx 518205 518199 0 16:26 ? 00:00:00 nginx: worker process
root 519789 208227 0 16:26 pts/3 00:00:00 grep --color=auto nginx