首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Zabbix安装实战

1.软件包下载:

软件版本:

PHP:

PHP 5.6.32 http://php.net/downloads.php

Apache:

系统上已经安装了RPM包的,2.4.6版本

如果采用RPM包安装,安装路径应在/etc/httpd目录下

apache配置文件:/etc/httpd/conf/httpd.conf

Apache模块路径:/usr/sbin/apachectl

web目录:/var/www/html

如果采用源代码安装,一般默认安装在/usr/local/apache2目录下

本次,我们删除系统原本安装的RPM包,采用源码方式安装

libxml2版本2.7.8 :http://download.chinaunix.net/download/0007000/6095.shtml,

pcre 8.4.1:http://sourceforge.net/projects/pcre/files/pcre/

libmcrypt 2.5.8 https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/

zabbix 3.4.6 https://www.zabbix.com/download

2.安装基础包

[root@YL1ECMS1Z10~]#yum install gccgcc-c++ expat-devel openssl-devel bzip2-devel curl-devel readline-devel libxslt-devellibjpeg-devel libpng-devel openldap-devel freetype-develnet-snmp-devellibevent-devel

3.安装libmcript

[root@YL1ECMS1Z10]# cd /usr/local

[root@YL1ECMS1Z10]# mkdir libmcript

[root@YL1ECMS1Z10]# mv /tmp/libmcrypt-2.5.8.tar.gz /usr/local/libmcrypt/

[root@YL1ECMS1Z10]# cd /usr/local/libmcrypt/

[root@YL1ECMS1Z10]# tar zxvf libmcrypt-2.5.8.tar.gz

[root@YL1ECMS1Z10]# cd libmcrypt-2.5.8/

[root@YL1ECMS1Z10]# ./configure--prefix=/usr/local/libmcrypt

[root@YL1ECMS1Z10]# make

[root@YL1ECMS1Z10]# make install

4.安装LNMP环境

1将所有软件包上传到/tmp目录

2安装MySQL

[root@YL1ECMS1Z10]# rpm –ivh mysql-community-libs-5.7.19-1.el7.x86_64

[root@YL1ECMS1Z10]# mysql-community-common-5.7.19-1.el7.x86_64

[root@YL1ECMS1Z10]# mysql-community-server-5.7.19-1.el7.x86_64

[root@YL1ECMS1Z10]# mysql-community-client-5.7.19-1.el7.x86_64

[root@YL1ECMS1Z10]# mysql-community-devel-5.7.19-1.el7.x86_64

安装完mysql后,重置一下mysql root密码,然后,启动mysql即可。

3安装apache

i.卸载原来已安装的软件包

[root@YL1ECMS1Z10]# rpm –qa|grep –i httpd

[root@YL1ECMS1Z10]#rpm –e httpd-tools-2.4.6-45.el7.x86_64httpd-2.4.6-45.el7.x86_64

ii.安装apr, apr-util

[root@YL1ECMS1Z10]#cd apr-1.6.3/

[root@YL1ECMS1Z10]#./configure--prefix=/usr/local/apr

[root@YL1ECMS1Z10]#make

[root@YL1ECMS1Z10]#make install

[root@YL1ECMS1Z10]#cd /usr/local

[root@YL1ECMS1Z10]#mkdir -p apr-util

[root@YL1ECMS1Z10]#cd /tmp

[root@YL1ECMS1Z10]#mv apr-util-1.6.1.tar.gz/usr/local/apr-util

[root@YL1ECMS1Z10]#cd /usr/local/apr-util

[root@YL1ECMS1Z10]#tar zxvf apr-util-1.6.1.tar.gz

[root@YL1ECMS1Z10]#cd apr-util-1.6.1/

[root@YL1ECMS1Z10]#./configure--prefix=/usr/local/apr-util –with-apr=/usr/local/apr/bin/apr-1-config

[root@YL1ECMS1Z10]#make

[root@YL1ECMS1Z10]#make install

iii.安装pcre

[root@YL1ECMS1Z10]#cd /usr/local

[root@YL1ECMS1Z10]#mkdir -p pcre

[root@YL1ECMS1Z10]#cd /tmp

[root@YL1ECMS1Z10]#mv pcre-8.41.zip/usr/local/pcre/

[root@YL1ECMS1Z10]#cd /usr/local/pcre

[root@YL1ECMS1Z10]#unzip pcre-8.41.zip

[root@YL1ECMS1Z10]#cd pcre-8.41 /

[root@YL1ECMS1Z10]#./configure--prefix=/usr/local/pcre

[root@YL1ECMS1Z10]#make

[root@YL1ECMS1Z10]#make install

iv.安装apache

[root@YL1ECMS1Z10]#mkdir -p /usr/local/apache2

[root@YL1ECMS1Z10]#cd/usr/local/apache2

[root@YL1ECMS1Z10]#mv /tmp/httpd-2.4.29.tar.gz./

[root@YL1ECMS1Z10]#tar zxvfhttpd-2.4.29.tar.gz

[root@YL1ECMS1Z10]#cd httpd-2.4.29/

[root@YL1ECMS1Z10]#./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

[root@YL1ECMS1Z10]#make

[root@YL1ECMS1Z10]#make install

v.配置apache

[root@prcist1lnmp1z10 conf]#vi /usr/local/apache2/conf/httpd.conf

修改设置:Listen :80

ServerName :80

[root@prcist1lnmp1z10 conf]#/usr/local/apache2/bin/apachectl start

4安装libxml2

[root@YL1ECMS1Z10]#mkdir -p/usr/local/libxml2

[root@YL1ECMS1Z10]#cp/tmp/libxml2-2.7.8.tar.gz /usr/local/libxml2/

[root@YL1ECMS1Z10]#cd/usr/local/libxml2

[root@YL1ECMS1Z10]#tar -zxvflibxml2-2.7.8.tar.gz

[root@YL1ECMS1Z10]#cd libxml2-2.7.8/

[root@YL1ECMS1Z10]#./configure--prefix=/usr/local/libxml2

[root@YL1ECMS1Z10]# make

[root@YL1ECMS1Z10]# make install

安装成功,在/usr/local/libxml2目录下会生成bin, include, lib, share四个目录。在PHP源代码包配置时,会通过configure命令选项加上“--with-libxml-dir=/usr/local/libxml2”,用于指定libxml2库文件的位置

5安装PHP

[root@YL1ECMS1Z10]# mkdir -p /usr/local/php

[root@YL1ECMS1Z10]# cd /usr/local/php

[root@YL1ECMS1Z10]#mv /tmp/php-5.6.32.tar.gz /usr/local/php/

[root@YL1ECMS1Z10]# tar zxvf php-5.6.32.tar.gz

[root@YL1ECMS1Z10]#cd php-5.6.32/

[root@YL1ECMS1Z10]# ./configure --prefix=/usr/local/php--sysconfdir=/etc/php --with-config-file-path=/etc/php--with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd--with-pcre-dir=/usr/local/pcre --with-mhash --with-openssl --with-zlib--with-bz2 --with-curl --with-gd --with-jpeg-dir --with-freetype-dir --with-zlib--enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-sockets--with-iconv-dir --with-pear--enable-session --enable-gd-native-ttf--enable-xml --enable-gd-jis-conv --enable-inline-optimization --enable-shared--enable-bcmath --enable-sysvmsg --enable-sysvsem --enable-sysvshm--enable-mbregex --enable-pcntl --with-xmlrpc --with-gettext --enable-exif--with-readline

[root@YL1ECMS1Z10]# make

[root@YL1ECMS1Z10]#make test

[root@YL1ECMS1Z10]# make install

6配置PHP

[root@PRCIST1ECMS2Z10 php-5.6.32]# cp php.ini-production/etc/php/php.ini

vi/etc/httpd/httpd.conf

1:添加:(编译时这个默认已经添加)

#LoadModule php7_module modules/libphp7.so --使用PHP7

LoadModule php5_module modules/libphp5.so

2:添加index.php:

3:文件最后添加:

SetHandlerapplication/x-httpd-php

4:找到AddTypeApplication/x-gzip.gz.tgz,在其下添加如下内容:

AddType Application/x-httpd-php .php

AddTypeApplication/x-httpd-php-source .phps

5:设置环境变量

[root@YL1ECMS1Z10]## vi web.sh

[root@YL1ECMS1Z10]# cat web.sh

export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin

6:配置/etc/php/php.ini

post_max_size =32M

max_execution_time = 300

max_input_time = 300

date.timezone = Asia/Shanghai

always_populate_raw_post_data = 1

5.安装zabbix

5.1. 上传软件包到/tmp/zabbix目录,并解压缩

[root@YL1ECMS1Z10 zabbix]# tarzxvf zabbix-3.4.6.tar.gz

5.2. 创建zabbix 用户和组

[root@YL1ECMS1Z10 zabbix-3.4.6]#groupadd zabbix

[root@YL1ECMS1Z10 zabbix-3.4.6]#useradd -g zabbix zabbix

5.3. 创建mysql数据库中的用户和数据库

[root@YL1ECMS1Z10 zabbix-3.4.6]#mysql -u root -p

mysql> create database zabbixcharacter set utf8 collate utf8_bin;

Query OK, 1 row affected (0.02sec)

mysql> grant all privileges onzabbix.* to zabbix@%localIP% identified by '%Password%';

Query OK, 0 rows affected, 1warning (0.00 sec)

5.4.创建数据库表

[root@YL1ECMS1Z10 zabbix-3.4.6]#pwd

/tmp/zabbix/zabbix-3.4.6

[root@YL1ECMS1Z10 zabbix-3.4.6]#cd database/mysql

[root@YL1ECMS1Z10 mysql]# ls

data.sql images.sql schema.sql

[root@YL1ECMS1Z10 mysql]# mysql-u zabbix -p zabbix -h 172.18.107.118

mysql>source schema.sql

mysql>source images.sql

mysql>source data.sql

5.5.安装Zabbix之前,需要先安装一系列软件包:

5.6.安装zabbix

[root@YL1ECMS1Z10 zabbix-3.4.6]# pwd

/tmp/zabbix/zabbix-3.4.6

[root@YL1ECMS1Z10 zabbix-3.4.6]# ./configure--enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl--with-libxml2=/usr/bin/xml2-config

6.将zabbix前端拷贝到(源文件的frontends/php)拷贝到web服务器的页面主目录下

[root@YL1ECMS1Z10 php]# pwd

/tmp/zabbix/zabbix-3.4.6/frontends/php

[root@YL1ECMS1Z10 php]# mkdir/usr/local/apache2/htdocs/zabbix

[root@YL1ECMS1Z10 php]# cp -a . /usr/local/apache2/htdocs/zabbix/

7.启动apache

[root@YL1ECMS1Z10 php]#/usr/local/apache2/bin/apachectl start

8.过web打开zabbix安装页面,http:///zabbix即可看到安装界面,按照刚才的配置设置一下,即可进入仪表盘界面。安装完成。

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180313G1SOHZ00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券