目录
一.环境介绍
角色 | 系统 | 安装内容 |
监控端server(192.168.43.101) | CentOS7.4 | LAMP架构、Zabbix-server |
被监控端clinet(192.168.43.102) | CentOS7.4 | Zabbix-agentd |
- 本实验搭建zabbix最简单的server-client架构,采用zabbix源码编译方式安装,LAMP架构采用yum安装
二.实验具体操作
在server端部署LAMP架构
环境准备
#永久修改主机名
[root@localhost ~]# hostnamectl set-hostname server
[root@localhost ~]# su
#正则关闭selinux核心防护
[root@server ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@server ~]# setenforce 0
#查看是否设置成功
[root@server ~]# getenforce 0
Permissive
#关闭防火墙
[root@server ~]# systemctl stop firewalld.service
[root@server ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server ~]#
安装软件包
- 安装apache
[root@server ~]# yum install -y httpd
- 安装mariadb
[root@server ~]# yum install -y mariadb mariadb-server
- 安装php以及扩展依赖包
[root@server ~]# yum install -y php php-bcmath php-mbstring \
> php-mysql php-gd php-ldap php-xml
- 安装依赖库
[root@server ~]# yum install -y unixODBC-devel mysql-devel \
> net-snmp-devel libxml2-devel libcurl-devel libevent-devel gcc
修改apache与php的配置文件
#配置apache
[root@server ~]# vi /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DocumentRoot "/var/www/html/zabbix"
[root@server ~]# mkdir -p /var/www/html/zabbix
[root@server ~]#
#配置php
vim /etc/php.ini
date.timezone = Asia/Shanghai //设置时区
post_max_size = 32M //设置上传文件大小
max_execution_time = 300
max_input_time = 300
always_populate_raw_post_data = -1
配置php界面
[root@server ~]# cat /var/www/html/zabbix/index.php
<?php
phpinfo();
?>
[root@server ~]#
启动服务并且验证php界面
[root@server ~]# systemctl start httpd.service
[root@server ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@server ~]# systemctl start mariadb.service
[root@server ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@server ~]#
初始化mariadb并且设置zabbix数据库用户
- 设置数据库
#设置安全导向
[root@server ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (en