1.环境准备
Zabbix官方安装文档地址
配置yum阿里源
[root@zabbix ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@zabbix ~]#
[root@zabbix ~]# setenforce 0
[root@zabbix ~]# systemctl stop firewalld
Mysql安装
采用yum安装
zabbix6.4依赖于Mysql8.0.30-8.1.X
配置Mysql源
[root@zabbix ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
[root@zabbix ~]# yum -y install mysql80-community-release-el7-5.noarch.rpm
安装相关依赖
[root@zabbix ~]# yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel
[root@zabbix ~]# yum list |grep mysql
[root@zabbix ~]# yum install -y mysql-community-server
初始化
[root@zabbix ~]# systemctl start mysqld
获取初始密码
[root@zabbix ~]# grep password /var/log/mysqld.log
[root@zabbix ~]# grep password /var/log/mysqld.log
2023-09-17T08:55:50.127189Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: MLI=NodA,670
[root@zabbix ~]# mysql -uroot -pMLI=NodA,670
mysql> alter user 'root'@'localhost' identified by 'Abc@123!';
修改密码权限
mysql> set global validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost' identified by '000000';
设置字符集utf-8
[root@zabbix ~]# vim /etc/my.cnf
[mysqld]
character-set-server=utf8
创建zabbix数据库,设置权限
mysql> create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'Abc@1234';
mysql> grant all privileges on *.* to 'zabbix'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Software | Mandatory status | Supported versions | Comments |
---|---|---|---|
MySQL/Percona | One of | 8.0.30-8.1.X | Required if MySQL (or Percona) is used as Zabbix backend database. InnoDB engine is required. MySQL 8.1 is supported since Zabbix 6.4.6. We recommend using the C API (libmysqlclient) library for building server/proxy. |
zabbix安装
获取安装包
wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.0.tar.gz
创建安装目录
[root@zabbix ~]# mkdir /usr/local/zabbix
[root@zabbix ~]# tar xf zabbix-6.4.0.tar.gz -C /usr/local/zabbix/
添加用户及组
[root@zabbix ~]# groupadd zabbix
[root@zabbix ~]# useradd zabbix -g zabbix -s /sbin/nologin
[root@zabbix zabbix-6.4.0]# cd /usr/local/zabbix/zabbix-6.4.0
编译
[root@zabbix zabbix-6.4.0]# ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql
切换gcc版本,centos7自带gcc版本无法成功安装
[root@zabbix zabbix-6.4.0]# yum install centos-release-scl -y
[root@zabbix zabbix-6.4.0]# yum install devtoolset-11-gcc* -y
切换版本,重启系统后无效
[root@zabbix zabbix-6.4.0]# scl enable devtoolset-11 bash
[root@zabbix zabbix-6.4.0]# gcc -v
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
[root@zabbix zabbix-6.4.0]# make install
导入数据库
[root@zabbix mysql]# mysql -uzabbix -pAbc@1234 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix mysql]# mysql -uzabbix -pAbc@1234 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix mysql]# mysql -uzabbix -pAbc@1234 zabbix < data.sql
修改zabbix配置文件
[root@zabbix zabbix-6.4.0]# cat conf/zabbix_server.conf |grep DBPassword
### Option: DBPassword
# DBPassword=
DBPassword=数据库zabbix用户密码
PHP安装
Software | Mandatory status | Version | Comments |
---|---|---|---|
Apache | One of | 2.4 or later | |
Nginx | 1.20 or later | ||
PHP | Yes | 7.4.0 - 8.2.X | It is recommended to use PHP 8.0 or newer, because PHP 7.4 is no longer supported by the vendor. |
php支持版本: 7.4.0 - 8.2.X
[root@zabbix ]# yum install -y yum-utils
添加yum源
[root@zabbix ~]# yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
启用php源
[root@zabbix ~]# yum-config-manager --disable 'remi-php*'
[root@zabbix ~]# yum-config-manager --enable remi-php80
开启php8 remi源
安装php及其拓展
[root@zabbix ~]# yum install -y php80
[root@zabbix ~]# yum -y install php php-bcmath php-gd php-xml php-mbstring php-mysqlnd php-ldap curl-devl libxml2 libxml2-devel
[root@zabbix ~]# php -v
PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
修改php配置
[root@zabbix ~]#vim /etc/php.ini
post_max_size=16M
max_execution_time=300
max_input_time=300
[root@zabbix ~]#
[root@zabbix ~]#
php支持版本: 7.4.0 - 8.2.X
[root@zabbix ]# yum install -y yum-utils
添加yum源
[root@zabbix ~]# yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
启用php源
[root@zabbix ~]# yum-config-manager --disable 'remi-php*'
[root@zabbix ~]# yum-config-manager --enable remi-php80
开启php8 remi源
安装php及其拓展
[root@zabbix ~]# yum install -y php80
[root@zabbix ~]# yum -y install php php-bcmath php-gd php-xml php-mbstring php-mysqlnd php-ldap curl-devl libxml2 libxml2-devel
[root@zabbix ~]# php -v
PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
修改php配置
[root@zabbix ~]#vim /etc/php.ini
修改post_max_size为16M
修改max_execution_time为300
修改max_input_time为300
[root@zabbix ~]#
[root@zabbix ~]#
Httpd安装
[root@zabbix ~]# yum install -y httpd
[root@zabbix ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: May 30 2023 14:01:11
添加web文件,设置文件权限
[root@zabbix zabbix-6.4.0]# cp -a ui/* /var/www/html/
[root@zabbix zabbix-6.4.0]# chown apache:apache -R /var/www/html/*
启动服务,设置开机自启
[root@zabbix zabbix-6.4.0]# systemctl start httpd
[root@zabbix zabbix-6.4.0]# systemctl enable httpd
启动zabbix_server服务
[root@zabbix ~]# export ZABBIX_HOME=/usr/local/zabbix
[root@zabbix ~]# export PATH=$PATH:$ZABBIX_HOME/sbin
访问本机IP:80
修改语言
安装完成
zabbix默认用户以及密码:
Admin/zabbix