(3)备份
[root@www nginx-1.25.4]# cd ~
[root@www ~]# cd /usr/local/nginx
[root@www nginx]# ls
client_body_temp conf fastcgi_temp html logs passwd.db proxy_temp sbin scgi_temp uwsgi_temp
[root@www nginx]# cd ..
[root@www local]# ls
bin etc games include lib lib64 libexec mysql nginx php sbin share src stress
[root@www local]# cp -pr ./nginx ./nginx_20240319_1.22.0
[root@www local]# ls
bin etc games include lib lib64 libexec mysql nginx nginx_20240319_1.22.0 php sbin share src stress
(4)解压
[root@www opt]# tar xf nginx-1.25.4.tar.gz
(5)编译
[root@www local]# cd /opt/nginx-1.25.4/
[root@www nginx-1.25.4]# ls
#这里指定的安装路径前缀和老的nginx保持一致
[root@www nginx-1.25.4]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@www nginx-1.25.4]# make
(6)验证
[root@www nginx-1.25.4]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@www nginx-1.25.4]# cd objs
[root@www objs]# ls
autoconf.err Makefile nginx nginx.8 ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_modules.o src
(7)备份旧的Nginx二进制
[root@www objs]# cd /usr/local/sbin
[root@www sbin]# ls
nginx php-fpm
[root@www sbin]# mv ./nginx ./nginx_1.22.0
[root@www sbin]# ls
nginx_1.22.0 php-fpm
(8)拷贝新的Nginx二进制
[root@www sbin]# cd ..
[root@www local]# ls
bin etc games include lib lib64 libexec mysql nginx nginx_20240319_1.22.0 php sbin share src stress
[root@www local]# cp -pr /opt/nginx-1.25.4/objs/nginx ./sbin
查看
[root@www local]# cd sbin
[root@www sbin]# ls
nginx nginx_1.22.0 php-fpm
(9)向旧的master发送USR2信号
查看旧的master进程PID为3142
[root@www sbin]# ps -ef | grep -E "CMD|nginx"
UID PID PPID C STIME TTY TIME CMD
root 3142 1 0 12:34 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 3143 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3144 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3145 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3146 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3147 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3148 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3149 3142 0 12:34 ? 00:00:00 nginx: worker process
nginx 3150 3142 0 12:34 ? 00:00:01 nginx: worker process
root 10884 3006 0 14:09 pts/1 00:00:00 grep --color=auto -E CMD|nginx
[root@www sbin]# ps axuw | head -1;ps axuw | grep nginx
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3142 0.0 0.0 20532 688 ? Ss 12:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 3143 0.0 0.1 24292 2964 ? S 12:34 0:00 nginx: worker process
nginx 3144 0.0 0.1 24292 2972 ? S 12:34 0:00 nginx: worker process
nginx 3145 0.0 0.1 24292 2968 ? S 12:34 0:00 nginx: worker process
nginx 3146 0.0 0.1 24292 2972 ? S 12:34 0:00 nginx: worker process
nginx 3147 0.0 0.1 24292 2968 ? S 12:34 0:00 nginx: worker process
nginx 3148 0.0 0.1 24292 2968 ? S 12:34 0:00 nginx: worker process
nginx 3149 0.0 0.1 24292 2972 ? S 12:34 0:00 nginx: worker process
nginx 3150 0.0 0.1 24292 2972 ? S 12:34 0:01 nginx: worker process
root 10922 0.0 0.0 112676 984 pts/1 S+ 14:10 0:00 grep --color=auto nginx
(10)确认nginx.pid位置
[root@www run]# cd /usr/local/nginx
[root@www nginx]# find ./ -name nginx.pid
./logs/nginx.pid
[root@www nginx]# cat ./logs/nginx.pid
3142
(11) 热升级
<