部署基于LAMP环境的ZABBIX

关闭防火墙

[root@zabbix-server ~]# systemctl stop firewalld.service #停止firewall
[root@zabbix-server ~]# systemctl disable firewalld.service #禁止firewall开机启动

关闭SeLinux

[root@zabbix-server ~]#  vi /etc/selinux/config
#SELINUX=enforcing #修改为 SELINUX=disabled
SELINUXTYPE=targeted #注释掉

安装LAMP环境
安装apache

[root@zabbix-server ~]# yum install httpd –y
[root@zabbix-server ~]# systemctl start httpd #启动apache
[root@zabbix-server ~]# systemctl enable httpd #设置apache开机启动

安装数据库MariaDB

[root@zabbix-server ~]# yum install mariadb-bench mariadb-devel mariadb-libs mariadb-server -y
[root@zabbix-server ~]# systemctl start mariadb   #启动MariaDB
[root@zabbix-server ~]# systemctl enable mariadb  #设置开机启动
[root@zabbix-server ~]# cp /usr/share/mysql/my-huge.cnf /etc/my.cnf  #拷贝配置文件

设置数据库密码

[root@zabbix-server ~]# mysql_secure_installation
[root@zabbix-server ~]# systemctl restart mariadb  #重启MariaDB

安装PHP

[root@zabbix-server ~]# yum install php –y
[root@zabbix-server ~]# yum install php-mysql php-gd libjpeg* php-ldap php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash –y #安装php组件支持 
[root@zabbix-server ~]# systemctl restart mariadb  #重启MariaDB

测试php

[root@zabbix-server ~]# cd /var/www/html
[root@zabbix-server html]# vi index.php
<?php
phpinfo();
?>
[root@zabbix-server ~]# chown apache.apache -R /var/www/html #赋予apache权限
[root@zabbix-server ~]# systemctl restart httpd  #重启apache,客户端浏览器输入http://<server_ip_or_name>

安装Zabbix
引入yum源 配置仓库包

[root@zabbix-server ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm 
[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y

创建zabbix数据库

[root@zabbix-server ~]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8;  #zabbix数据库可以和zabbix服务器分离,采用Mariadb服务器存储数据,需要给zabbix数据库受相应的权限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%';  
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uroot -p zabbix #导入数据库 

修改zabbix配置文件

[root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=root
DBPassword=zabbix
[root@zabbix-server ~]#  systemctl start zabbix-server    #启动zabbix-server
[root@zabbix-server ~]#  systemctl enable zabbix-server  #设置zabbix-server开机启动

配置PHP

[root@zabbix-server ~]#  sed -i.ori ‘18a php_value date.timezone  Asia/Shanghai‘ /etc/httpd/conf.d/zabbix.conf #更改时区设置
重启Mariadb、httpd、zabbix-server、zabbix-agent并设置zabbix-agent开机自启
[root@zabbix-server ~]#  systemctl restart mariadb
[root@zabbix-server ~]#  systemctl restart httpd
[root@zabbix-server ~]#  systemctl restart zabbix-server
[root@zabbix-server ~]#  systemctl restart zabbix-agent
[root@zabbix-server ~]#  systemctl enable zabbix-agent

WEB配置
客户端浏览器输入http://<server_ip_or_name>/zabbix
根据提示完成配置,默认账号密码 Admin / zabbix

发布了55 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_46192300/article/details/104393513