目录
本文记录了编译安装的nginx1.18平滑升级到nginx1.22版本的流程,都采用的编译安装,有不清楚流程的可以评论区@我,咱们一起讨论。
编译安装nginx1.18
# 安装编译依赖
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
useradd -s /sbin/nologin nginx
tar zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
make
make install
# 启动nginx
/usr/local/nginx/sbin/nginx
平滑升级至1.22版本
tar zxvf nginx-1.22.0.tar.gz
## 注意:一些操作都是在该目录完成
cd nginx-1.22.0
# 配置
# --pid-path 指定nginx的pid文件存放位置
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-stream --pid-path=/usr/local/nginx/logs/nginx.pid
# 编译
make
# 备份旧版本,复制新版本
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/
chown nginx:nginx /usr/local/nginx/sbin/nginx
# 升级
make upgrade
## 以下是回显可以参考一下
[root@node2 nginx-1.22.0]# make upgrade
/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
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@node2 nginx-1.22.0]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.22.0