nginx-1.16.1 自动化安装及Prometheus监控配置

nginx-1.16.1 自动化安装及Prometheus监控配置

环境介绍

操作系统: CentOS7.6

Nginx-1.16.1

软件准备:

# Nginx下载: 
wget http://nginx.org/download/nginx-1.16.1.tar.gz

# pcre 下载: https://ftp.pcre.org/pub/pcre/
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz

# zlib 下载: 
wget https://fossies.org/linux/misc/zlib-1.2.11.tar.gz

# openssl 下载: 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. 安装基础工具:

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

2. 安装 Nginx-1.16.1

cd /usr/local/src/

3. 创建nginx用户:

useradd nginx

解压:

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. 环境变量配置

在/etc/profile 中加入:

export NGINX_HOME=/usr/local/nginx

export PATH=$PATH:$NGINX_HOME/sbin

5. 开机启动配置

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

加入开机启动

systemctl enable nginx .service

systemctl status nginx .service

systemctl restart nginx .service

6. prometheus监控nginx

插件

https://github.com/hnlq715/nginx-vts-exporter

模板

https://grafana.com/grafana/dashboards/2949

原文链接: https://www.cnblogs.com/miaocbin/p/12343227.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/193400

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午6:21
下一篇 2023年2月12日 下午6:22

相关推荐