码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-02-21 22:06:28      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:模板   bsp   des   lin   dashboard   multi   for   gcc-c++   evel   

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

 

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

标签:模板   bsp   des   lin   dashboard   multi   for   gcc-c++   evel   

原文地址:https://www.cnblogs.com/miaocbin/p/12343227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!