openresty安装及增加upstream_check_module


  1. 安装依赖包
    1
    yum install -y pcre-devel openssl-devel gcc curl make wget git patch
  2. 下载openresty安装包
    1
    2
    mkdir -p /root/source
    wget https://openresty.org/download/openresty-1.21.4.1.tar.gz -O /root/source/openresty-1.21.4.1.tar.gz
  3. 解压安装包
    1
    tar -zxvf /root/source/openresty-1.21.4.1.tar.gz
  4. 下载upstream_check_module
    1
    2
    cd /root/source/openresty-1.21.4.1/bundle
    git clone https://mirror.ghproxy.com/https://github.com/xiaokai-wang/nginx_upstream_check_module.git
  5. 编译安装upstream_check_module
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    cd /root/source/openresty-1.21.4.1/bundle/nginx-1.21.4
    patch -p1<../nginx_upstream_check_module/check_1.20.1+.patch

    cd ..
    ./configure --prefix=/usr/local/openresty \
    --user=www --group=www \
    --with-http_stub_status_module \
    --with-http_realip_module \
    --with-http_gzip_static_module \
    --with-http_v2_module \
    --with-luajit \
    --with-http_ssl_module \
    --with-http_addition_module \
    --with-http_v2_module \
    --add-module=./bundle/nginx_upstream_check_module

    make -j4
    make install
  6. 配置系统服务
    1
    vim /usr/lib/systemd/system/openresty.service
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [Unit]
    Description=openresty
    After=network.target

    [Service]
    Type=forking
    ExecStart=/usr/local/openresty/nginx/sbin/nginx
    ExecReload=/usr/local/openresty/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/openresty/nginx/sbin/nginx -s quit
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target
    1
    2
    systemctl daemon-reload
    systemctl start openresty