centos7上zabbix监控lnmp(nginx)+wordpress服务

实验要求:

zabbix+grafana 并实现微信报警和邮件报警,使用lnmp+wordpress 完成web,并用zabbix监控,并实时告警

实现 lnmp+wordpress
1.安装epel-release

[root@localhost ~]# yum -y install epel-release

2.安装lnmp相关组件 上传WordPress包

[root@localhost ~]# yum -y install nginx mariadb mariadb-server php php-server php-mysql php-gd php-fpm php-devel

3.修改nginx配置文件

[root@192 ~]# cd /etc/nginx/
[root@192 nginx]# mv nginx.conf.default nginx.conf
[root@192 nginx]# vim nginx.conf
location = /50x.html {
            root   html;
        }
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

4.编写index.php

[root@localhost ~]# cat /var/www/html/index.php 
<?php
phpinfo();
?>

启动服务

[root@localhost ~]# systemctl start nginx mariadb php-fpm

访问
在这里插入图片描述
部署wordpress,把wordpress包放到/var/www/html

[root@localhost html]# unzip wordpress-4.9.4-zh_CN.zip
[root@localhost html]# chmod -R 777 /var/www/html/
[root@192 html]# mysql
MariaDB [(none)]> create database wh character set utf8;
[root@192 html]# cp wp-config-sample.php wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wh');

/** MySQL数据库用户名 */
define('DB_USER', 'root');

/** MySQL数据库密码 */
define('DB_PASSWORD', '');

/** MySQL主机 */
define('DB_HOST', 'localhost');

在这里插入图片描述
在这里插入图片描述

使用zabbix监控nginx

1 客户端配置yum源

[root@localhost ~]# cat /etc/yum.repos.d/zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
 
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

2 安装zabbix-agent

yum -y install zabbix-agent

3 编辑zabbix_agentd.conf
在这里插入图片描述
4 开启服务

systemctl enable zabbix-agent
 systemctl start zabbix-agent

配置主机组
在这里插入图片描述
在这里插入图片描述
创建主机
在这里插入图片描述
在这里插入图片描述
在zabbix服务器上测试键值是否可以获取到数据

  1. 安装zabbix-get工具
yum -y install zabbix-get
  1. 通过zabbix_get命令测试键值
zabbix_get -s 192.168.227.170 -k net.tcp.listen[80]

若返回值是1的话,说明Apache端口正在监听
若返回值是0的话,说明Apache端口没有监听

创建监控项
在这里插入图片描述
在这里插入图片描述
创建触发器
在这里插入图片描述
在这里插入图片描述
创建图形
在这里插入图片描述
在这里插入图片描述
打开zabbix 前端告警
在这里插入图片描述
停止nginx服务验证告警

[root@localhost ~]# systemctl stop nginx

在这里插入图片描述
恢复服务

[root@localhost ~]# systemctl start nginx

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值