一、环境及版本信息:

l  Redhat 7.1

l  Zabbix 3.4.12 source

二、安装步骤

1.         tar –zxvf zabbix-*

2.         创建运行zabbix的用户。必须步骤。如果zabbix serveragent运行在同一主机上,为了安全考虑,建议使用不同的用户。

groupadd  --system zabbix

useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

为了后续部分自定义功能用到zabbix家目录,可以创建它

mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix

chown zabbix:zabbix /usr/lib/zabbix

3.         创建zabbix使用的数据库。Zabbix serverzabbix proxy安装之前必须创建zabbix database

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';

导入数据和表结构,数据在源码包的database下面:

shell> cd database/mysql

shell> mysql -uzabbix -p<password> zabbix < schema.sql

如果是创建zabbix proxy,后面不用执行:

shell> mysql -uzabbix -p<password> zabbix < images.sql

shell> mysql -uzabbix -p<password> zabbix < data.sql

4.         编译安装,不指定安装路径,默认daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) 安装在in /usr/local/sbin the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

安装在zabbix agent上,使用以下命令编译:

./configure --enable-agent

make install

——————————————————————————————错误——————

错误:configure: error: Not found mysqlclient library

解决方法:yum install mysql-devel

错误:error: LIBXML2 library not found

解决方法:yum install libxml2-devel

错误:configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

解决方法:yum install net-snmp-devel –y

错误:configure: error: Unable to use libevent (libevent check failed)

解决方法:rpm -ivh libevent-devel   [libevent-devel-2.0.21-4.el7.x86_64,rhel7安装此版本,rpmfind.net]

错误:configure: error: Curl library not found

解决方法:yum install libcurl-devel

错误:configure: error: Unable to use libpcre (libpcre check failed)

解决方法:yum install -y pcre-devel

 

5.         启动zabbix server。修改zabbix_server的配置文件,将其中的数据库名称,数据库用户名,数据库密码填写正确。

Zabbix配置文件/usr/local/zabbix/etc:

blob.pngspacer.gif

启动zabbix

sbin/zabbix_server

6.         配置php server,为了配置zabbix前端显示,需要php后端服务器,这里使用apache httpd + php实现。在服务器上安装httpdhttpd-2.4.6)和php(php-5.4.16)

yum install httpd

yum install php

yum install php-mysql php-gd libjpeg* php-odbc php-pear php-xml php-xmlrpc

预检查时需要php-mbstring, php-bcmath,需要提前安装,无法找到对应版本,可强制安装高版本。

blob.png

配置httpd服务器,vim httpd.conf,修改以下配置:

找到:

 

AddType application/x-gzip .gz .tgz

 

在该行下面添加

 

AddType application/x-httpd-php .php

修改DirectoryIndex index.htmlDirectoryIndex index.html index.htm index.php

httpd根目录下面建立测试php文件:

blob.png

从浏览器访问结果:

blob.png

将源码中的frontend/php拷贝到/var/www/html/zabbix下面,访问http://9.38.90.200/zabbix/会报错:PHP Parse error:  syntax error, unexpected '[' in /var/www/html/zabbix/index.php on line 32,这是因为php版本较低,需要安装php 5.4以上版本,rhel6.6的镜像中是php5.3,需要升级php5.4以上版本。

blob.png

7.         登陆zabbix

 初始用户名密码:Admin/zabbix