//最新的nginx的安装包
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.20.2 nginx-1.20.2.tar.gz
[root@localhost ~]#
[root@localhost ~]# wget http://nginx.org/download/nginx-1.22.0.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.20.2 nginx-1.20.2.tar.gz nginx-1.22.0.tar.gz
[root@localhost ~]#
//下载git包
[root@localhost ~]# yum -y install git
//下载nginx更新安装包
[root@localhost ~]# git clone https://gitee.com/wujunze/nginx_module_echo.git
Cloning into 'nginx_module_echo'...
remote: Enumerating objects: 80, done.
remote: Total 80 (delta 0), reused 0 (delta 0), pack-reused 80
Receiving objects: 100% (80/80), 14.34 KiB | 1.43 MiB/s, done.
Resolving deltas: 100% (37/37), done.
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.20.2.tar.gz nginx_module_echo
nginx-1.20.2 nginx-1.22.0.tar.gz
[root@localhost ~]#
//添加新的功能
[root@localhost ~]# cd nginx-1.22.0/
[root@localhost nginx-1.22.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.22.0]# ./configure --help
--add-module=PATH enable external module
里面有添加新的模块的功能
[root@localhost nginx-1.22.0]# ./configure --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 --add-module=../nginx_module_echo
[root@localhost nginx-1.22.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l)
[root@localhost nginx-1.22.0]# ls
auto CHANGES.ru configure html Makefile objs src
CHANGES conf contrib LICENSE man README
[root@localhost nginx-1.22.0]# objs/nginx -v
nginx version: nginx/1.22.0
[root@localhost nginx-1.22.0]#
[root@localhost nginx-1.22.0]# du -sh objs/nginx
6.0M objs/nginx
[root@localhost nginx-1.22.0]#
平滑升级过程:
获取老版本的编译信息
获取新版本安装包或功能包
配置新版本或功能,配置时加上老版本的编译信息和新版本或功能(--add-module)
编译,编译完后不能执行安装操作备份老版本程序,使用复制的方式
停掉老版本程序的进程
将新版本程序复制到老版本所在位置替换掉老版本启动新版本
[root@localhost nginx-1.22.0]# cp /usr/local/nginx/sbin/nginx{,-bak};pkill nginx;cp objs/nginx /usr/local/nginx/sbin/nginx;systemctl start nginx
cp: overwrite '/usr/local/nginx/sbin/nginx-bak'? y
cp: overwrite '/usr/local/nginx/sbin/nginx'? y
[root@localhost nginx-1.22.0]#
[root@localhost nginx-1.22.0]# nginx -v
nginx version: nginx/1.22.0
[root@localhost nginx-1.22.0]#
[root@localhost ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 192.168.119.157:8081 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]#