码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-05-05 17:55:49      阅读:456      评论:0      收藏:0      [点我收藏+]

标签:lamp;zabbix

一、快速搭建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

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

技术分享

安装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/images.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(图示)

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

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

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

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

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


技术分享

默认登录名:admin  密码:zabbix





本文出自 “11382081” 博客,请务必保留此出处http://11392081.blog.51cto.com/11382081/1770368

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

标签:lamp;zabbix

原文地址:http://11392081.blog.51cto.com/11382081/1770368

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!