系统中已经运行了一个版本的nginx的进程:
1、编译生成心得可执行程序
tar zxf nginx-1.16.0.tar.gz
vim auto/cc/gcc
./configure --prefix=/usr/local/nginx --with-file-aio
make 只make不安装
2、在线升级
cd ~/nginx-1.16.0/objs
cp -f nginx /usr/local/nginx/sbin/nginx
ps -ef | grep nginx
root 18034 1 0 10:45 ? 00:00:00 nginx: master process nginx
nginx 18035 18034 0 10:45 ? 00:00:00 nginx: worker process
nginx 18036 18034 0 10:45 ? 00:00:00 nginx: worker process
root 18232 1406 0 10:48 pts/0 00:00:00 grep --color=auto nginx
kill -USR2 18034(master进程) //使worker不在接收请求,同时打开新版本的nginx的master进程,和它的两个线程,实现热升级
ps -ef | grep nginx //旧版进程和新版进程同时存在
root 18034 1 0 10:45 ? 00:00:00 nginx: master process nginx
nginx 18035 18034 0 10:45 ? 00:00:00 nginx: worker process
nginx 18036 18034 0 10:45 ? 00:00:00 nginx: worker process
root 18126 18034 0 10:46