nginx-1.16.1 Automated installation and configuration monitoring Prometheus
Environment Introduction
Operating System: CentOS7.6
Nginx-1.16.1
Software preparation:
# Nginx Download: wget HTTP: // nginx.org/download/nginx-1.16.1.tar.gz # PCRE Download: HTTPS: // ftp.pcre.org/pub/pcre/ wget HTTPS: // ftp.pcre .org / Pub / PCRE / PCRE-8.43.tar.gz # zlib Download: wget HTTPS: // fossies.org/linux/misc/zlib-1.2.11.tar.gz # OpenSSL Download: HTTP: // distfiles. macports.org/openssl/ wget HTTP: // distfiles.macports.org/openssl/openssl-1.0.2s.tar.gz # nginx_upstream_check_module HTTPS: // github.com/yaoweibin/nginx_upstream_check_module wget HTTPS: //github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
1. Install the basic tools:
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2. Install Nginx-1.16.1
cd /usr/local/src/
3. Create nginx users:
useradd nginx
Decompression:
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --prefix=/usr/local/nginx-1.16.1 --with-http_ssl_module --with-http_gzip_static_module --with-pcre=/usr/local/src/pcre-8.43 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.0.2s --with-http_stub_status_module --with-http_realip_module --add-module=/usr/local/src/nginx_upstream_check_module-master --with-http_sysguard_module --add-module=nginx-module-vts
make
make install
4. environment variable configuration
In the / etc / profile was added:
Export NGINX_HOME = / usr / local / Nginx
Export the PATH the PATH = $: $ NGINX_HOME / sbin
5. boot configuration
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
User=nginx
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
# Join boot
systemctl enable nginx .service
systemctl Status nginx .service
systemctl restart nginx .service
6. prometheus monitoring nginx
# Plug
https://github.com/hnlq715/nginx-vts-exporter
Template #
https://grafana.com/grafana/dashboards/2949