前期准备:
安装mysql5.6和php5.6(本文后面有讲如何安装php),想知道怎么装mysql的请出门左转(在centos7安装mysql6

  1. 下载zabbix源码zabbix-3.4.6.tar.gz,网页地址:https://www.zabbix.com/downlo...
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.6/zabbix-3.4.6.tar.gz
  1. 解压进入目录
tar -zxvf zabbix-3.4.6.tar.gz
cd zabbix-3.4.6
  1. 创建zabbix用户(不然启动zabbix服务或zabbix代理是不给的)
groupadd zabbix
useradd -g zabbix zabbix
  1. 配置源码,zabbix分为服务端zabbix_server和zabbix_agentd,以下配置时服务端的配置
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  1. 编译安装
make install 
  1. zabbix分为服务端zabbix_server和zabbix_agentd,安装好服务端后,就修改服务端的配置 /usr/local/etc/zabbix_server.conf
### Option: DBHost  数据库地址
#    Database host name.
#    If set to localhost, socket is used for MySQL.
#    If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
DBHost=localhost

### Option: DBName  数据库名称
#    Database name.
#    For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix


### Option: DBUser  数据库账号
#    Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword 数据库密码
#    Database password. Ignored for SQLite.
#    Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zabbix

  1. 运行数据库脚本zabbix支持mysqMySQL、PostgreSQL、Oracle、IBM DB2和SQLite数据库,我们就挑最常用的mysql
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
shell> cd database/mysql
shell> mysql -uzabbix -p<password> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < images.sql
shell> mysql -uzabbix -p<password> zabbix < data.sql
  1. 启动服务端
zabbix_server
  1. 新建zabbix的页面目录
mkdir /var/www/html/zabbix
  1. 复制zabbix的php目录到刚刚创建的目录里
cd frontends/php
cp -a . /var/www/html/zabbix
  1. 访问页面,开始配置数据库等信息(注意,这是页面接口,跟刚刚zabbix_server是两回事,不要以为刚刚配置的zabbix_server.conf配置了数据库就没事了)
http://192.168.31.190/zabbix
  1. 这时候访问页面会发现zabbix检查到一些依赖没配置好:
Minimum required size of PHP post is 16M (configuration option "post_max_size").
Minimum required limit on execution time of PHP scripts is 300 (configuration option "max_execution_time").
Minimum required limit on input parse time for PHP scripts is 300 (configuration option "max_input_time").
Time zone for PHP is not set (configuration parameter "date.timezone").
PHP bcmath extension missing (PHP configuration parameter --enable-bcmath).
PHP option "always_populate_raw_post_data" must be set to "-1"
  1. 此时需要修改 /etc/php.ini把上述配置修改好
date.timezone = Asia/Shanghai
extension=bcmath.so
  1. 重启httpd
systemctl restart httpd
  1. 然后在重新访问zabbix页面,就没fail的检查,然后下一步,配置数据库信息,再下一步,设置zabbix_server的域名和zabbix_server的监听端口(再次提醒,zabbix_server和php页面是两回事,不是同一个东西),如果zabbix_server的域名和端口配置错误,在zabbix的dashboard里显示Zabbix server is running是no
  2. 页面生成一个php的配置文件zabbix.conf.php,下载下来,然后放在/var/www/html/zabbix/conf/目录下面。
  3. 这样zabbix就安装成功了,默认账号密码(name is Admin, password zabbix),剩下的就是配置agentd节点了。

安装apache和php

安装apache和php,可以参考《centos6.7下搭配apache php mysql环境》,注意那篇文章安装的可能是php5.3,如果是5.3会报错:

syntax error, unexpected '[' in /var/www/html/zabbix/index.php on line 32

官网说https://support.zabbix.com/br...
需要php5.4以上。于是卸载了php5.3,重新安装5.6

yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-xml.x86_64 php56w-bcmath.x86_64

如果镜像没有,需先安装镜像

  Centos 5.X
    rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
  CentOs 6.x
    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  CentOs 7.X
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

TroubleShoot

  1. MySQL library not found
yum install mysql-devel -y
  1. LIBXML2 not found
yum install libxml2-devel -y
  1. Invalid Net-SNMP directory - unable to find net-snmp-config
yum install net-snmp-devel -y
  1. Unable to use libevent (libevent check failed)
yum install libevent-devel -y
  1. Curl library not found
yum install curl-devel -y
  1. WARNING: 'aclocal-1.15' is missing on your system.
6.1安装autoconf-2.63-5.1.el6.noarch.rpmautomake-1.11.1-4.el6.noarch.rpm
6.2 运行
autoreconf -ivf

电脑杂技集团
208 声望32 粉丝

这家伙好像很懂计算机~