一、快速搭建LAMP环境

1、配置本地yum源

[root@zabbix ~]# mount /dev/cdrom /mnt

[root@zabbix ~]# vi /etc/yum.repos.d/rhel-source.repo 

[rhel-source]

name=rhel-source

baseurl=file:///mnt

enabled=1

gpgcheck=0

#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[root@zabbix ~]# yum clean all

[root@zabbix ~]# yum list


2、配置apache2

[root@zabbix ~]# yum -y install httpd

[root@zabbix ~]# /etc/init.d/httpd start


3、安装mysql

[root@zabbix ~]# yum -y install mysql mysql-server

[root@zabbix ~]# /etc/init.d/mysqld start

修改root密码为1234

[root@zabbix ~]# /usr/bin/mysqladmin -u root password '1234'

登录测试:[root@zabbix ~]# mysql -u root -p


4、安装php5

[root@zabbix ~]# yum -y install php

安装完重启apache使php生效

[root@zabbix ~]# /etc/init.d/httpd restart

测试apache+php是否正确安装:

[root@zabbix ~]# echo "<?php phpinfo(); ?>" > /var/www/html/info.php

打开浏览器,效果如下图所示:

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix

安装php-mysql模块

[root@zabbix ~]# yum -y install php-mysql

重启apache

[root@zabbix ~]# /etc/init.d/httpd restart


5、设置LAMP组件为开机自动启动

[root@zabbix ~]# chkconfig --levels 2345 httpd on

[root@zabbix ~]# chkconfig --levels 2345 mysqld on


二、搭建zabbix服务器

1、yum和rpm安装组件

[root@zabbix ~]# yum install make mysql-server httpd php mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-xml

下载php-mbstring和php-bcmath的rpm包,然后安装

[root@zabbix ~]# rpm -ivh php-mbstring-5.3.3-3.el6_1.3.x86_64.rpm

[root@zabbix ~]# rpm -ivh php-bcmath-5.3.3-3.el6_2.8.x86_64.rpm --nodeps


2、将zabbix-2.0.6上传到/usr/local/src/目录下,并解压

[root@zabbix ~]# cd /usr/local/src/

[root@zabbix src]# rz -ab

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


3、新建zabbix用户,并创建数据库

[root@zabbix ~]# useradd zabbix

[root@zabbix ~]# mysql -u root -p

mysql> create database zabbix character set utf8;

mysql> grant all on zabbix.* TO zabbix@'localhost' identified by 'zabbixpass';

mysql> flush privileges;

mysql> use zabbix;

mysql> source /usr/local/src/zabbix-2.0.6/database/mysql/schema.sql

mysql> source /usr/local/src/zabbix-2.0.6/database/mysql/p_w_picpaths.sql

mysql> source /usr/local/src/zabbix-2.0.6/database/mysql/data.sql


4、编译安装zabbix-2.0.6

[root@zabbix zabbix-2.0.6]# ./configure --with-mysql --with-libcurl --with-net-snmp --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix

[root@zabbix zabbix-2.0.6]# make && make install

[root@zabbix zabbix-2.0.6]# date -s '2016-5-5 12:38:12'


5、添加端口

[root@zabbix zabbix-2.0.6]# vi /etc/services

zabbix-agent    10050/tcp                 # Zabbix Agent

zabbix-agent    10050/udp               # Zabbix Agent

zabbix-trapper  10051/tcp                # Zabbix Trapper

zabbix-trapper  10051/udp              # Zabbix Trapper


6、修改配置文件

[root@zabbix zabbix-2.0.6]# vi /etc/httpd/conf/httpd.conf

DirectoryIndex index.html index.html.var index.php


[root@zabbix zabbix-2.0.6]# sed -i 's#LogFile=/tmp/zabbix_server.log#LogFile=/var/log/zabbix_server.log#g' /usr/local/zabbix/etc/zabbix_server.conf

[root@zabbix zabbix-2.0.6]# echo "DBPassword=1234" >> /usr/local/zabbix/etc/zabbix_server.conf

[root@zabbix zabbix-2.0.6]# grep -vEn '^#|""|^$' /usr/local/zabbix/etc/zabbix_server.conf

[root@zabbix zabbix-2.0.6]# touch /var/log/zabbix_server.log

[root@zabbix zabbix-2.0.6]# chmod 777 /var/log/zabbix_server.log


[root@zabbix zabbix-2.0.6]# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/

[root@zabbix zabbix-2.0.6]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

[root@zabbix zabbix-2.0.6]# chmod 777 /etc/init.d/zabbix_*


[root@zabbix zabbix-2.0.6]# sed -i 's#ZABBIX_BIN="/usr/local/sbin/zabbix_server"#ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"#g' /etc/init.d/zabbix_server

[root@zabbix zabbix-2.0.6]# head -n 21 /etc/init.d/zabbix_server | tail -n 1


[root@zabbix zabbix-2.0.6]# sed -i 's#ZABBIX_BIN="/usr/local/sbin/zabbix_agentd"#ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"#g' /etc/init.d/zabbix_agentd 

[root@zabbix zabbix-2.0.6]# head -n 21 /etc/init.d/zabbix_agentd | tail -n 1


7、启动服务并设置加入到开机启动项

[root@zabbix zabbix-2.0.6]# /etc/init.d/zabbix_server start

[root@zabbix zabbix-2.0.6]# /etc/init.d/zabbix_agentd start

[root@zabbix zabbix-2.0.6]# chkconfig zabbix_server on

[root@zabbix zabbix-2.0.6]# chkconfig zabbix_agentd on


8、修改php参数并配置php文件

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

max_execution_time = 300

max_input_time = 300

date.timezone = PRC

post_max_size = 32M


[root@zabbix zabbix-2.0.6]# cd frontends/

[root@zabbix frontends]# cp -rf php /var/www/html/

[root@zabbix frontends]# cd /var/www/html/

[root@zabbix html]# mv php zabbix

[root@zabbix html]# chown -R zabbix:zabbix zabbix


9、安装zabbix(图示)

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_02

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_03

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_04

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_05

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_06

RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_07

注意:上图如果出现failed,需要执行如下操作

1)点击下方的download下载文件

2)cd到文件所在的目录,执行:

[root@zabbix html]# cp /root/Downloads/zabbix.conf.php /var/www/html/zabbix/conf/


RHEL 6.2下快速搭建LAMP环境和zabbix 2.0.6_LAMP;Zabbix_08

默认登录名:admin  密码:zabbix