1.zabbix服务端安装
在安装zabbix服务之前,先搭建好lamp
//下载zabbix,解压
[root@zzg ~]# cd /usr/src/
[root@zzg src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz
[root@zzg src]# tar xf zabbix-3.4.12.tar.gz
//安装依赖包
[root@zzg src]# yum -y install net-snmp-devel libevent-devel
//创建zabbix用户和组
[root@zzg src]# groupadd -r zabbix
[root@zzg src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
//配置zabbix数据库
[root@zzg src]# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@zzg src]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@zzg mysql]# ls
data.sql images.sql schema.sql
[root@zzg mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zzg mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zzg mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
//编译安装zabbix
[root@zzg mysql]# cd /usr/src/zabbix-3.4.12
[root@zzg zabbix-3.4.12]# [root@localhost zabbix-4.0.3]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
[root@zzg zabbix-3.4.12]# make install
2.zabbix服务端配置
//修改服务端配置文件,设置数据库信息
[root@zzg ~]# cd /usr/local/etc/
[root@zzg etc]# ls
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@zzg etc]# vim zabbix_server.conf
DBPassword=zabbix123! //设置zabbix数据库连接密码
//启动zabbix_server和zabbix_agentd
[root@zzg etc]# zabbix_server
[root@zzg etc]# zabbix_agentd
3.zabbix服务端web界面安装与配置
//修改/etc/php.ini的配置并重启php-fpm
[root@zzg etc]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@zzg etc]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini[root@zzg etc]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@zzg etc]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@zzg etc]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@zzg ~]# cd /usr/local/apache/htdocs/
[root@zzg htdocs]# mkdir zabbix
[root@zzg htdocs]# cp -ar /usr/src/zabbix-3.4.12/frontends/php/* zabbix/
[root@zzg htdocs]# chown -R apache.apache /usr/local/apache/htdocs/
//配置apache虚拟主机
[root@zzg htdocs]# vim /etc/httpd24/httpd.conf
[root@zzg htdocs]# tail -12 /etc/httpd24/httpd.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName www.zabbix.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@zzg htdocs]# apachectl -t
Syntax OK
//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@zzg htdocs]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
//重启服务
[root@zzg htdocs]# apachectl stop
[root@zzg htdocs]# apachectl start
[root@zzg htdocs]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
//关闭防火墙,selinux
[root@zzg htdocs]# systemctl stop firewalld
[root@zzg htdocs]# setenforce 0
4. 安装zabbix web界面
安在浏览器上访问域名进行安装:装zabbix web界面
恢复zabbix/conf目录的权限为755:
[root@zzg htdocs]# chmod 755 /usr/local/apache/htdocs/zabbix/conf