下载依赖包
dnf -y install net-snmp-devel libevent-devel libxml2 libxml2-devel curl-devel
解压安装包,创建用户和组
[root@localhost ~]# tar xf zabbix-5.2.6.tar.gz
[root@localhost ~]# cd zabbix-5.2.6
[root@localhost zabbix-5.2.6]# useradd -r -M -s /sbin/nologin zabbix
配置zabbix数据库
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'zabbix'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all on *.* to zabbix@'192.168.11.136' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
将数据导入数据库
[root@localhost ~]# cd /root/zabbix-5.2.6/
[root@localhost zabbix-5.2.6]# ls
AUTHORS Makefile.in build configure install-sh sass
COPYING NEWS compile configure.ac m4 src
ChangeLog README conf database man ui
INSTALL aclocal.m4 config.guess depcomp misc
Makefile.am bin config.sub include missing
[root@localhost zabbix-5.2.6]# cd database/mysql/
[root@localhost mysql]# ls
Makefile.am Makefile.in data.sql double.sql images.sql schema.sql
[root@localhost mysql]# mysql -uzabbix -proot zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -proot zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -proot zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
编译安装zabbix
[root@localhost zabbix-5.2.6]# ./configure --enable-server \
--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-libxml2
[root@localhost zabbix-5.2.6]# make install
配置zabbix_server.conf文件,取消注释填写自己的zabbix的mysql用户的密码
[root@localhost zabbix-5.2.6]# cd /usr/local/etc/
[root@localhost etc]# vi zabbix_server.conf
DBPassword=root
启动zabbix_server和zabbix_agentd
[root@localhost etc]# zabbix_server
[root@localhost etc]# zabbix_agentd
[root@localhost etc]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
创建zabbix根目录并将二进制包中的ui目录下的程序复制到zabbix的根目录中设置属主和属组
[root@localhost /]# mv /usr/local/apache/htdocs/huang /usr/local/apache/htdocs/zabbix
[root@localhost /]# cp -r /root/zabbix-5.2.6/ui/* /usr/local/apache/htdocs/zabbix/
[root@localhost /]# chown -R apache.apache /usr/local/apache/htdocs
配置虚拟主机并重启apache服务
[root@localhost ~]# vi /etc/httpd24/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName www.huang.com
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apach
e/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
~
修改etc/php.ini的配置并重启php服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@localhost ~]# service php-fpm restart
修改/usr/local/apache/htdocs/zabbix/conf的权限,这样才能自动生成数据库连接文件
[root@localhost ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
关闭防火墙和selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld