zoukankan      html  css  js  c++  java
  • nginx make upgrade 平滑升级

    [root@localhost ~]# /usr/local/nginx/sbin/nginx -V
    nginx version: nginx/1.15.9
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module --add-module=/root/ngx_http_substitutions_filter_module
    
    • 下载最新的nginx,(官方下载地址:http://nginx.org/en/download.html)
    [root@localhost ~]# wget -c http://nginx.org/download/nginx-1.17.0.tar.gz
    --2019-06-19 12:37:46--  http://nginx.org/download/nginx-1.17.0.tar.gz
    Resolving nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3
    Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected.
    HTTP request sent, awaiting response... 206 Partial Content
    Length: 1032978 (1009K), 1016293 (992K) remaining [application/octet-stream]
    Saving to: nginx-1.17.0.tar.gz
    
    100%[++=======================================================================================================================================>] 1,032,978   33.9KB/s   in 33s    
    
    2019-06-19 12:38:19 (30.3 KB/s) - nginx-1.17.0.tar.gz saved [1032978/1032978]
    
    [root@localhost ~]# 
    • 解压nginx-1.17.0.tar.gz,并cd到解压目录
    [root@localhost ~]# tar -zxvf nginx-1.17.0.tar.gz
    ………………………………………………………………
    nginx-1.17.0/auto/cc/name
    nginx-1.17.0/auto/cc/owc
    nginx-1.17.0/auto/cc/sunc
    [root@localhost ~]# cd nginx-1.17.0
    [root@localhost nginx-1.17.0]# 
    • 配置安装选项,要和我们上面查询版本时所查看到的配置保持一致,要不你可就少安装功能了,导致一些功能不可用了。
    [root@localhost nginx-1.17.0]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module --add-module=/root/ngx_http_substitutions_filter_module
    checking for OS
     + Linux 3.10.0-957.1.3.el7.x86_64 x86_64
    checking for C compiler ... found
     + using GNU C compiler
     + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
    ………………………………………………………………………………………………………………………………………………
    ………………………………………………………………………………………………………………………………………………
    ./configure –help 查看详细的说明帮助 生成makefile文件
    • 编译
    [root@localhost nginx-1.17.0]# make
    ……………………………………………………………………………………
    ……………………………………………………………………………………
    sed -e "s|%%PREFIX%%|/usr/local/nginx|" 
    	-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" 
    	-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" 
    	-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" 
    	< man/nginx.8 > objs/nginx.8
    make[1]: Leaving directory `/root/nginx-1.17.0'
    将高级语言生成二进制语言
    • 运行平滑升级命令
    [root@localhost nginx-1.17.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@localhost nginx-1.17.0]# 

    注:到这里运行平滑级后,升级并没有完成,需要再次编译安装才可以,原本第一次认为到这里升级就结束了,但查询版本号还是原来的版本。

    • 编译安装
    [root@localhost nginx-1.17.0]# make install
    安装到想应目录
    第二种方法
    #先将之前的nginx先备份
    mv /usr/local/nginx/sbin/nginx /usr/local/nginx.bak
    #将make好的nginx拷贝到原来nginx安装目录/usr/local/nginx/sbin
     cp -rp objs/nginx /usr/local/nginx/sbin/
    #平滑启动
    make upgrade

    至此我们的平滑升级结束,我们可以再次查询nginx的版本号。

    • nginx版本查询
    [root@localhost nginx-1.17.0]# /usr/local/nginx/sbin/nginx -V
     
  • 相关阅读:
    URL解析模式(伪静态)
    PHP各环境下的伪静态配置
    亚马逊-购书(电子)
    前端路由-JS实现
    SpringBoot 2.3.0.RELEASE版本后自定义404页面,SpringBoot 404错误兼容Ajax请求
    不设置DIV宽度水平居中,div不设置宽度居中
    js 保留两位小数,Js四舍五入,JavaScript Math四舍五入
    Laravel 自定义公共函数的引入
    EF Core3.1 CodeFirst动态自动添加表和字段的描述信息
    Android 高德地图API INVALID_USER_SCODE 错误
  • 原文地址:https://www.cnblogs.com/executive-1314/p/13277875.html
Copyright © 2011-2022 走看看