一 服务端配置
1.配置前先关闭iptables和SELINUX,避免安装过程中报错

[root@localhost tw]# service iptables stop
iptables: Flushing firewall rules: [  OK  ]
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Unloading modules: [  OK  ]
[root@localhost tw]# chkconfig iptables off
[root@localhost tw]# getenforce
Disabled

2.安装LAMP环境

[root@localhost tw]# yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear

3.下载zabbix-2.0.6.tar.gz

[root@localhost tw]# wget 

4.安装zabbix所需的组件(server,agent)

[root@localhost tw]yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI

5.创建用户账号(server,agent)

[root@localhost tw]#useradd zabbix

[root@localhost tw]#usermod -s /sbin/nologin zabbix

6.创建zabbix数据库并导入zabbix数据库(server)

[root@localhost tw]#tar zxf zabbix-2.0.6.tar.gz

[root@localhost tw]#mysqladmin -u root password 123456

[root@localhost tw] mysql -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
mysql> use zabbix;
mysql> source /tw/zabbix-2.0.6/database/mysql/schema.sql
mysql> source /tw/zabbix-2.0.6/database/mysql/p_w_picpaths.sql
mysql> source /tw/zabbix-2.0.6/database/mysql/data.sql
mysql> exit

7.编译安装,如果是客户端安装选择--enable-agent就行了。

[root@localhost tw]#cd zabbix-2.0.6

[root@localhost zabbix-2.0.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl

8.编辑配置文件

[root@localhost zabbix-2.0.6]#cd /usr/local/etc

[root@localhost zabbix-2.0.6]# cp zabbix_server.conf zabbix_server.conf.bak

[root@localhost etc]# cp zabbix_agentd.conf  zabbix_agentd.conf.bak

[root@localhost etc]# more zabbix_server.conf #服务端的配置
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
[root@localhost etc]# more zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
UnsafeUserParameters=1
[root@localhost etc]# touch /var/log/zabbix_server.log
[root@localhost etc]# touch /var/log/zabbix_agentd.log
[root@localhost etc]# chmod 777 /var/log/zabbix_*

9.启动服务(server,agent)

[root@localhost etc]cd /tw/zabbix-2.0.6

[root@localhost zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_server /etc/init.d/
[root@localhost zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
[root@localhost zabbix-2.0.6]# chmod +x /etc/init.d/zabbix_*
添加服务
[root@localhost zabbix-2.0.6]# chkconfig --add zabbix_server
[root@localhost zabbix-2.0.6]# chkconfig --add zabbix_agentd
设置服务器开机自动启动 

注:执行chkconfig时如出现zabbix_server 服务不支持 chkconfig,编辑zabbix_server和zabbix_agentd中开头添加以下内容即可(#chkconfig:345 61 61)

[root@localhost zabbix-2.0.6]# chkconfig zabbix_server on
[root@localhost zabbix-2.0.6]# chkconfig zabbix_agentd on
[root@localhost zabbix-2.0.6]# /etc/init.d/zabbix_server start
Zabbix server started.
[root@localhost zabbix-2.0.6]# /etc/init.d/zabbix_agentd start
[root@localhost zabbix-2.0.6]# ps -ef |grep zabbix
zabbix    1803     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1805  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1806  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1807  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1808  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1814     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_server
root      2043  2006  0 08:23 pts/0    00:00:00 grep zabbix
[root@localhost zabbix-2.0.6]# netstat -lantp |grep 10050
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1803/zabbix_agentd
[root@localhost zabbix-2.0.6]#netstat -lantp |grep 10051
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      2308/zabbix_server

10.安装zabbix web界面(httpd)

复制php文件,zabbix的终端程序是用php写的,因此需要一个支持php脚本解析的web服务器。然后将frontends/php下面的php文件拷贝到web服务器html文件目录下面。

[root@localhost zabbix-2.0.6]#cp -r frontends/php /var/www/html/zabbix

[root@localhost zabbix-2.0.6]#/etc/init.d/httpd restart #启动apache服务

11.安装zabbix web界面(nginx)

1.安装php

yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php-pecl* 

2.安装nginx

[root@localhost]#wget 

[root@localhost]#tar zxf nginx-1.9.9.tar.gz

[root@localhost]#cd nginx-1.9.9

[root@localhost nginx-1.9.9]#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log

[root@localhost nginx-1.9.9]#make && make install

3.配置nginx参数(修改成下列内容支持PHP)

[root@localhost zabbix-2.0.6]#cp -r frontends/php /usr/local/nginx/html/zabbix

[root@localhost zabbix-2.0.6]#vi /usr/local/nginx/conf/nginx.conf

    server {

        listen       88;

        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

            root   html/zabbix;

            index  index.php index.htm index.html;

        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php$ {

            root           html/zabbix;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }

4.启动

[root@localhost zabbix-2.0.6]#chown -R /usr/local/nginx

[root@localhost zabbix-2.0.6]#/usr/local/nginx/sbin/nginx           //启动nginx

[root@localhost zabbix-2.0.6]#/etc/init.d/php-fpm start          //启动php

11.修改PHP参数

[root@localhost zabbix-2.0.6]# vi /etc/php.ini

[Date]

; Defines the default timezone used by the date functions

date.timezone = Asia/Shanghai    #修改一下时区
[root@localhost zabbix-2.0.6]# /etc/init.d/httpd restart

在浏览器里输入localhost/zabbix出现zabbix安装界面点击next,下一步出现PHP bacmath  no   Fail错误

[root@localhost zabbix-2.0.6]#yum install -y php-bcmath     #安装php-bcmath即可

其他报错,根据提示修改/etc/php.ini文件里的参数即可,然后next,配置如下

Database type:MySQL

Database host:localhost

Database port:3306

Database name:zabbix

user         :zabbix

Password     :123456

点击Test connection出现OK继续next,配置如下

HOST          :localhost

Port          :10051

Name          :zabbix

配置完成继续next,出现登录界面输入用户名/密码为默认:admin/zabbix

11.配置中文界面

登录后点击右上角的Profile在里面Language选项选择Chinese(zh_CN)然后save即可