Nginx 升级

2 篇文章 0 订阅
1 篇文章 0 订阅

Nginx 升级

  1. 需要查看原来安装的nginx的版本以及编译的参数(安装了那些模块)

    nginx -V
    
    [root@cctc-contract-web-01 ~]# nginx -V
    nginx version: nginx/1.18.0
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/ --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-stream --with-stream_ssl_module --with-http_slice_module --with-file-aio --with-http_v2_module
    
  2. 下载需要升级的nginx版本,解压

    tar -zxvf nginx-1.22.0.tar.gz
    
  3. 解压进入目录开始运行上面所查询到的编译参数

    cd nginx-1.22.0
    ./configure --prefix=/ --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-stream --with-stream_ssl_module --with-http_slice_module --with-file-aio --with-http_v2_module
    
  4. 然后make,但不要make install

    make
    
  5. 备份旧的nginx二进制文件

    mv /usr/sbin/nginx /usr/sbin/nginx.old_20220803
    
  6. 替换新的nginx

    mv /root/nginx-1.22.0/objs/nginx /usr/sbin/nginx
    
  7. 查看当前nginx版本

    nginx -v
    
  8. 查看当前nginx进程情况

    ps -ef | grep nginx
    
    [root@cctc-contract-web-01 ~]# ps -ef | grep nginx
    root      64354      1  0 6月24 ?       00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    nginx     64355  64354  0 6月24 ?       00:00:03 nginx: worker process
    nginx     64356  64354  0 6月24 ?       00:00:14 nginx: worker process
    nginx     64357  64354  0 6月24 ?       00:01:42 nginx: worker process
    nginx     64358  64354  0 6月24 ?       00:01:11 nginx: worker process
    
  9. 向旧nginx主线程发送升级信号

    kill -USR2 64354
    
  10. 此时再次查看nginx进程 有新旧2个nginx进程

    [root@cctc-contract-web-01 ~]# ps -ef | grep nginx
    root      64354      1  0 6月24 ?       00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    nginx     64355  64354  0 6月24 ?       00:00:03 nginx: worker process
    nginx     64356  64354  0 6月24 ?       00:00:14 nginx: worker process
    nginx     64357  64354  0 6月24 ?       00:01:42 nginx: worker process
    nginx     64358  64354  0 6月24 ?       00:01:11 nginx: worker process
    root     130058  64354  0 23:43 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    nginx    130059 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130060 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130061 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130062 130058  0 23:43 ?        00:00:00 nginx: worker process
    
  11. 优雅关闭旧nginx线程(会保留旧的主线程,若服务没问题则可以kill掉该线程)

    kill -WINCH 64354
    
    [root@cctc-contract-web-01 sbin]# ps -ef | grep nginx
    root      64354      1  0 6月24 ?       00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    root     130058  64354  0 23:43 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    nginx    130059 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130060 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130061 130058  0 23:43 ?        00:00:00 nginx: worker process
    nginx    130062 130058  0 23:43 ?        00:00:00 nginx: worker process
    
  12. 回滚

    kill -HUP 64354
    
  13. 关闭旧的nginx进程

    kill -QUIT 64354
    
  14. 异常问题解决

    • Q:

      checking for C compiler ... not found
      
      ./configure: error: C compiler cc is not found
      

      A:

      yum -y install gcc-c++
      
    • Q:

      checking for gcc -pipe switch ... found
      checking for --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... not found
      ./configure: error: the invalid value in --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E"
      

      A:

       yum install redhat-rpm-config
      
    • Q:

      ./configure: error: the HTTP rewrite module requires the PCRE library.
      You can either disable the module by using --without-http_rewrite_module
      option, or install the PCRE library into the system, or build the PCRE library
      statically from the source with nginx by using --with-pcre=<path> option.
      

      A:

      yum install pcre-devel  openssl-devel
      
    • Q:

      ./configure: error: the HTTP XSLT module requires the libxml2/libxslt
      libraries. You can either do not enable the module or install the libraries.
      

      A:

      yum install libxslt-devel
      
    • Q:

      ./configure: error: the HTTP image filter module requires the GD library.
      You can either do not enable the module or install the libraries.
      

      A:

      yum install gd-devel
      
    • Q:

      ./configure: error: perl module ExtUtils::Embed is required
      

      A:

      yum install perl-ExtUtils-Embed
      
    • Q:

      ./configure: error: the Google perftools module requires the Google perftools
      library. You can either do not enable the module or install the library.
      

      A:

      yum install gperftools-devel
      
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值