[Monitoring] Shell scripts for installing and deploying OpenResty and Nginx monitoring plugins in CentOS

illustrate

The script will first install the necessary dependencies, then download and install OpenResty, and then download and install the Nginx monitoring plugin. Finally start OpenResty. Note that this script is only applicable to the CentOS system, if you need to install it on other operating systems, please refer to the official documentation.

screenplay

#!/bin/bash

# Step 1:安装依赖
sudo yum install -y wget openssl-devel pcre-devel gcc make git

# Step 2:下载并安装 OpenResty
wget https://openresty.org/download/openresty-1.19.9.1.tar.gz
tar -xzvf openresty-1.19.9.1.tar.gz
cd openresty-1.19.9.1

./configure --prefix=/usr/local/openresty \
            --with-http_stub_status_module \
            --with-pcre-jit \
            --with-http_realip_module \
            --with-http_addition_module \
            --with-http_sub_module \
            --with-http_ssl_module \
            --with-pcre

make -j2
sudo make install

# Step 3:下载并安装 Nginx 监控插件
cd /usr/local/openresty/nginx
sudo mkdir conf.d
sudo wget https://raw.githubusercontent.com/vozlt/nginx-module-vts/master/conf/nginx.conf
sudo wget https://raw.githubusercontent.com/vozlt/nginx-module-vts/master/statistics/format_jsonp.js
sudo wget https://raw.githubusercontent.com/vozlt/nginx-module-vts/master/statistics/format_prometheus.pl
sudo wget https://raw.githubusercontent.com/vozlt/nginx-module-vts/master/statistics/format_json.pl

# Step 4:启动 OpenResty
sudo /usr/local/openresty/nginx/sbin/nginx

echo "OpenResty 安装完成!"

Guess you like

Origin blog.csdn.net/qq_38428623/article/details/130066529