zoukankan      html  css  js  c++  java
  • linux服务器升级nginx

    1、简介

      有时候nginx发布了新BUG或者添加了新的功能时,想要更新的时候服务又不能中断,这时候就要用到nginx的平滑升级了。

      该脚本同样适用于添加新扩展,添加新扩展的时候只需要把更新的版本修改为当前版本,更新的时候把需要添加的扩展加上去即可。

      我这里nginx安装目录为/usr/local/nginx

      当前系统,阿里云ECS CentOS 7.4 64位

    2、查看nginx版本与编译信息

      # /usr/local/nginx/sbin/nginx -V

      

      这里的扩展要记录下来(重要),等下升级的时候用到,如果有需要添加新信息可以一起编译。

    2、使用shell升级

      cnl_function.sh cnl_install_lnmp_init.sh 下载地址

      更新的时候请修改自己的安装目录

     1 #!/bin/bash
     2 source ./cnl_function.sh
     3 source ./cnl_install_lnmp_init.sh
     4 #function of install nginx
     5 update_nginx(){
     6     cd /usr/local/src
     7     [ -f nginx-1.15.6.tar.gz ] || wget http://nginx.org/download/nginx-1.15.6.tar.gz 
     8     tar -zxf nginx-1.15.6.tar.gz
     9     cd nginx-1.15.6
    10     myum pcre-devel    
    11     [ -d /usr/local/nginx ] && cp -R /usr/local/nginx /usr/local/nginx_`date +%s`
    12     check_ok
    13     ./configure 
    14     --prefix=/usr/local/nginx 
    15     --with-http_stub_status_module 
    16     --with-http_ssl_module 
    17     --with-ipv6 
    18     --with-http_v2_module 
    19     --with-poll_module 
    20     --with-http_realip_module 
    21     --with-http_sub_module 
    22     --with-http_gzip_static_module 
    23     --with-http_dav_module 
    24     --with-http_flv_module
    25     #只编译不安装
    26     make
    27     check_ok    
    28     if [ -f /usr/local/nginx/sbin/nginx ] 
    29     then
    30         mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
    31         check_ok
    32     fi
    33     
    34     cp /usr/local/src/nginx-1.15.6/objs/nginx /usr/local/nginx/sbin/
    35     check_ok
    36     
    37     kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
    38     check_ok
    39 
    40 }
    41 
    42 read -p "Initialization completion, Enter  (Y) to start update nginx1.15.6 :" n
    43 if [ $n == 'Y' ]
    44 then
    45     echo "Start update==============================================================================================================================>"
    46     update_nginx
    47     echo "The update_nginx make done"
    48 else
    49     echo "Cancel the update."
    50 fi

       进到shell脚本目录执行该脚本,按提示执行即可。

       

      执行完可以看到nginx版本已经升级为1.15.6

     

    写的文章仅供自己参考,仅供自己参考,仅供自己参考,免得太久没有使用忘记了。
  • 相关阅读:
    Tencent 闲聊对话机器人接口调用,画像:设计员小白
    logging模块简介python
    jieba分词的几种形式
    h5py这个坑-PyCharm Process finished with exit code -1073741819 (0xC0000005)
    python之six模块的用法six.py2 six.py3
    Swoole从入门到入土(8)——协程初探
    Swoole从入门到入土(7)——TCP服务器[大杂烩]
    Swoole从入门到入土(6)——TCP服务器[粘包]
    Swoole从入门到入土(5)——TCP服务器[异步任务]
    Swoole从入门到入土(4)——TCP服务器[正确重启]
  • 原文地址:https://www.cnblogs.com/chennl/p/10172060.html
Copyright © 2011-2022 走看看