nginx通过shell脚本平滑升级版本
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx通过shell脚本平滑升级版本,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1930字,纯文字阅读大概需要3分钟。
内容图文
1、简介有时候nginx发布了新BUG或者添加了新的功能时,想要更新的时候服务又不能中断,这时候就要用到nginx的平滑升级了。
该脚本同样适用于添加新扩展,添加新扩展的时候只需要把更新的版本修改为当前版本,更新的时候把需要添加的扩展加上去即可。
我这里nginx安装目录为/usr/local/nginx
当前系统,阿里云ECS CentOS 7 64位
2、查看nginx版本与编译信息
/usr/local/nginx/sbin/nginx -V
注:这里的扩展要记录下来(重要),等下升级的时候用到,如果有需要添加新信息可以一起编译。
3、使用shell脚本平滑升级nginx版本
shell 脚本:---------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
source ./cnl_function.sh
source ./cnl_install_lnmp_init.sh
#function of install nginx
updatenginx(){
cd /usr/local/src
[ -f nginx-1.15.9.tar.gz ] || wget http://nginx.org/download/nginx-1.15.9.tar.gz
tar -zxf nginx-1.15.9.tar.gz
cd nginx-1.15.9
myum pcre-devel
[ -d /usr/local/nginx ] && cp -R /usr/local/nginx /usr/local/nginxdate +%s
check_ok
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-ipv6 \
--with-http_v2_module \
--with-poll_module \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_dav_module \
--with-http_flv_module
#只编译不安装
make
check_ok
if [ -f /usr/local/nginx/sbin/nginx ]
then
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
check_ok
fi
cp /usr/local/src/nginx-1.15.9/objs/nginx /usr/local/nginx/sbin/
check_ok
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
check_ok
}
read -p "Initialization completion, Enter (Y) to start update nginx1.15.6 :" n
if [ $n == ‘Y‘ ]
then
echo "Start update==============================================================================================================================>"
update_nginx
echo "The update_nginx make done"
else
echo "Cancel the update."
fi
shell 脚本:---------------------------------------------------------------------------------------------------------------------------------
4、脚本授权,运行脚本,并查看nginx版本是否升级成功
chmod o+x
./updata.sh
/usr/local/nginx/sbin/nginx -V
原文:https://blog.51cto.com/byu46123/2360099
内容总结
以上是互联网集市为您收集整理的nginx通过shell脚本平滑升级版本全部内容,希望文章能够帮你解决nginx通过shell脚本平滑升级版本所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。