您的位置:首页 > 运维架构 > Nginx

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

2020-06-06 05:00 183 查看

实验要求:

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: