目录
查看当前 Nginx 编译参数
# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.15.7
built by gcc 4.8.2 20141223 (Red Hat 4.8.5-5) (GCC)
built with OpenSSL 1.21.1a 21 Nov 2016
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx
升级nginx
下载新版Nginx
cd ~
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar xzvf nginx-1.16.1.tar.gz
编译Nginx
- configure
cd nginx-1.16.1/
./configure --user=www --group=www --prefix=/usr/local/nginx
这里的 configure需跟上边 nginx -V 的编译参数一致。文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
- make
注意:这里一定
不要
执行 make install文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
替换旧的程序并重启
-
备份旧的执行程序文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
-
替换新的执行程序文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
cp objs/nginx /usr/local/nginx/sbin/
-
检查nginx配置文件是否正常文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
# /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
-
查看nginx版本文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
/usr/local/nginx/sbin/nginx -V
此时已经变成了新版本文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
重启
找到 nginx.pid 文件文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
kill -USR2 cat /usr/local/nginx/logs/nginx.pid
此时会生成一个新的文件:文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
/usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT cat /usr/local/nginx/logs/nginx.pid.oldbin
回滚方案
将备份的nginx还原并重启即可文章源自编程技术分享-https://mervyn.life/1db2b3f1.html
mv /usr/local/nginx/sbin/nginx.bak /usr/local/nginx/sbin/nginx
kill -USR2 cat /usr/local/nginx/logs/nginx.pid
kill -QUIT cat /usr/local/nginx/logs/nginx.pid.oldbin
文章源自编程技术分享-https://mervyn.life/1db2b3f1.html 我的微信公众号
微信扫一扫
评论