• Nginx版本升级


    一、部署搭建

    ## Nginx1.18.0安装
    首先得编译环境(gcc、g++、make)的准备,其次得准备prce、zlib,前者为了重写rewrite,后者为了gzip压缩。
    **1、编译环境准备**
    centos平台编译环境使用如下指令
    安装make:
    ```powershell
    yum -y install gcc automake autoconf libtool make
    ```
    安装g++:
    ```powershell
    yum install gcc gcc-c++
    ```
    **2、选定源文件存放目录**
    建议自己在根目录建立一个softtool文件夹
    ```powershell
    cd /softtool
    ```
    **3、安装pcre**
    https://ftp.pcre.org/pub/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:
    ```powershell
    cd /softtool
    wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz 
    tar -zxvf pcre-8.44.tar.gz
    cd pcre-8.44
    ./configure
    make
    make install
    ```
    **4、安装zlib**
    http://zlib.net/zlib-1.2.11.tar.gz 下载最新的 zlib 源码包,使用下面命令下载编译和安装 zlib包:
    ```powershell
    cd /softtool 
    wget http://zlib.net/zlib-1.2.11.tar.gz
    tar -zxvf zlib-1.2.11.tar.gz
    cd zlib-1.2.11
    ./configure
    make
    make install
    ```
    **5、安装openssl**
    下载地址:https://www.openssl.org/source/openssl-1.1.1g.tar.gz
    ```powershell
    cd /usr/local/src
    wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
    tar -zxvf openssl-1.1.1g.tar.gz
    ```
    **6、安装Nginx1.18.0**
    源码下载地址:http://nginx.org/download/nginx-1.18.0.tar.gz
    ```powershell
    cd /softtool
    wget http://nginx.org/download/nginx-1.18.0.tar.gz
    tar -zxvf nginx-1.18.0.tar.gz
    cd nginx-1.18.0
     
    ./configure --sbin-path=/usr/local/nginx/nginx \
    --conf-path=/usr/local/nginx/nginx.conf \
    --pid-path=/usr/local/nginx/nginx.pid \
    --with-http_gzip_static_module \
    --with-http_stub_status_module \
    --with-file-aio \
    --with-http_realip_module \
    --with-http_ssl_module \
    --with-pcre=/softtool/pcre-8.44 \
    --with-zlib=/softtool/zlib-1.2.11 \
    --with-openssl=/softtool/openssl-1.1.1g
     
    make 
    make install
    ```
    --with-pcre=/usr/local/src/pcre-8.44 指的是pcre-8.44 的源码路径。
    --with-zlib=/usr/local/src/zlib-1.2.11指的是zlib-1.2.11 的源码路径。
    **6、启动**
    确保系统的 80 端口没被其他程序占用,运行/usr/local/nginx/nginx 命令来启动 Nginx
    ```powershell
    netstat -ano|grep 80
    ```
    进入bin目录
    ./nginx     //启动
    kill -9 pid   //杀死进程
    ./nginx -s reload    //重启

    参考与:https://www.nginx.cn/install

    二、版本升级

    简介:一般nginx版本升级主要是用于,安全漏洞修复。

    nginx版本下载地址:http://nginx.org/en/download.html

    1、查看nginx版本以及openssl版本
    [root@host sbin]# ./nginx -V

    2、备份原来nginx程序文件(usr/local/nginx/sbin目录下)
    mv nginx nginx-1.18

    3、将压缩包上传到服务器进行解压,上传任意位置,没有要求,解压tar xf nginx-1.20.1.tar.gz
    [root@host 下载]# cd nginx-1.20.1/

    [root@hos nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module(此处configure参数根据./nginx -V打印出来参数进行配置)

    [root@host nginx-1.20.1]# make

    4、复制nginx-1.20.1下的nginx到原来的nginx目录下,注意nginx-1.20.1中nginx在objs目录下而不是在sbin下面
    [root@host nginx-1.20.1]# cd objs/ 
    [root@host objs]# cp nginx /usr/local/nginx/sbin/

    5、测试是否替换成功
    [root@host sbin]# /usr/local/nginx/sbin/nginx -t
    [root@host sbin]# /usr/local/nginx/sbin/nginx -V

  • 相关阅读:
    Shell脚本学习
    Cholesterol艾美捷胆固醇基参方案
    postgresql-子查询
    Java之线程详解(三)——多线程常用API、七种状态、优先级、Lock锁
    研发效能最佳实践:持续集成应用实践丨IDCF
    Docker 入门篇(二)-- Linux 环境离线安装
    Java Html转Word
    Jetpack Compose 1.5 发布:全新 Modifier 系统助力性能提升
    STL-stack、queue和priority_queue的模拟实现
    wsl kali-linux 安装记录
  • 原文地址:https://blog.csdn.net/LuMaman/article/details/133315650