欢迎关注“程序杂货铺”公众号,里面有精彩内容,欢迎大家收看^_^

由于zabbix server需要依赖MySQL及PHP的相关依赖,因此需要先安装好MySQL及PHP的相关依赖后方可安装zabbixserver。

安装MySQL

目录mysql下的rpm

1.新建mysql用户

useradd mysql;

passwd mysql;

2.用root用户

先查看有没有冲突,rpm -qa|grep mysql 如果已经有了卸载 rpm -e --nodeps

rpm -ivh mysql-community-common-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-compact-

rpm -ivh mysql-community-client-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-server-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-dev*

全安装方式ls *|xargs rpm -ivh

3.按照自己规划的目录修改。

使用root修改/etc/my.cnf

datadir=/home/mysql/datadir

log-error=/home/mysql/logs/mysqld.log

pid-file=/home/mysql/mysqld/mysqld.pid

使用mysql用户创建上述目录 datadir logs及mysqld

//chown -R mysql:mysql /home/mysql/datadir

//chown -R mysql:mysql /home/mysql/logs/

//chown -R mysql:mysql /home/mysql/mysqld/

//根据/etc/my.cnf创建相应的文件,并授权

//mkdir -p /var/run/mysql

//mkdir -p /var/log/mysql

//chown -R mysql:mysql /var/log/mysql

//chown -R mysql:mysql /var/run/mysql

//注:/etc/my.cnf中没有basedir路径,需要添加

//basedir=/usr/local/mysql

4初始化数据库

使用root用户

cd /usr/bin

4.1创建一个有随机密码的root账户, 

mysqld --initialize --user=mysql

初始化成功后,查看该随机密码vi /home/mysql/logs/mysqld.log,最后一行记录了密码

使用mysql -u root -p,输入随机密码就可以登录

4.2 创建一个没有密码的root账户

mysqld --initialize-insecure --user=mysql

使用命令mysql -u root--skip-password 登录

注:初始化时,mysqld服务会检查数据目录是否存在:

如果数据目录不存在,mysqld则会创建它。

如果数据目录存在,且不是空目录(即包含有文件或子目录),mysqld会显示一条错误信息并中止:

       [ERROR] --initialize specified but thedata

        directory exists. Aborting.

解决方案: 将数据目录重命名后,重新再初始化一次 mv /var/lib/mysql  /var/lib/mysql.bak8. 

4.配置mysql服务开机自动启动

#检查自启动项列表中没有mysqld这个,如果没有就添加mysqld:

chkconfig --list mysqld

chkconfig --add mysqld

#设置开机启动

chkconfig mysqld on

5.关闭SELinux(安全控制模块)

查看是否关闭getenforce 或者sestatus -v

如果没有执行命令 setenforce 0 命令设置临时关闭,不用重启生效

或者vi /etc/sysconfig/selinux 永久关闭 SELINUX=disabled

5.启动mysql

#启动mysqld服务

service mysqld start

#检查mysqld是否已经启动

service mysqld status

6修改mysql用户密码(初始root密码文件在/home/mysql/log/mysqld.log)

mysql -u root -p 

mysql -u root --skip-password

mysql>alter user 'root'@'localhost' identified by 'unicom';

7.已root用户身份登录

mysql -uroot -punicom

8.赋权 (若已含有zabbix_new则需要,否则不需要执行)

grant all on zabbix_new.* to zabbix

安装PHP及相关依赖

1.检查gcc 及g++编译器(make 时需要,centos编译器目录)

gcc -v

g++ -v

如果没有g++

rpm -ivh libstdc-++**

rpm -ivh gcc-c++**

可以强制安装(慎用):

rpm -ivh --force gcc-2.96-110.i386.rpm

rpm -ivh --nodeps --replacefilesgcc-c++-4.4.7-4.el6.x86_64.rpm (不依赖替代升级)

2.安装openssl(httpd需要),httpd依赖目录

检查rpm -qa|grep-i openssl

如果没有需要安装

rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm

rpm -ivh keyutils-libs-devel-1.4-4.el6.x86_64.rpm

rpm -ivh libcom_err-devel-1.41.12-18.el6.x86_64.rpm

rpm -ivh libsepol-devel-2.0.41-4.el6.x86_64.rpm

rpm -ivh libselinux-devel-2.0.94-5.3.el6_4.1.x86_64.rpm

rpm -ivh krb5-devel-1.10.3-10.el6_4.6.x86_64.rpm

rpm -ivh openssl-devel-1.0.1e-15.el6.x86_64.rpm

全安装ls *|xargs rpm -ivh

3.安装libmcrypt

解压包    tar -xzvf libmcrypt-2.5.8.tar.gz

cdlibmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt/ --with-zlib=/usr/local/zlib/

make

make install

4.安装httpd

httpd-2.2.29.tar.gz解压

./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl--with-ssl=/usr/lib64/ --enable-cgi

make

make install

修改/etc/httpd/conf/httpd.conf在httpd.conf 里加入如下几句

AddTypeapplication/x-httpd-PHP .php

LoadModulephp5_module modules/libphp5 .so

<IfModulemod_php5.c>

       AddType application/x-httpd-php .php

       AddType application/x-httpd-php-source .phps

       </IfModule>

        做软连接

ln -s /usr/local/apache2/modules/libphp5.so /usr/lib64/httpd/modules/libphp5.so(php安装完了之后才有)

5.安装libxml2 及 libxml2-devel是否安装了(php需要)

检测是否安装了 rpm -qa|grep libxml2

rpm -ivh rpm -ivh libxml2-devel-2.7.6-14.el6.x86_64.rpm

检查/usr/lib/下是否有libxml2,若没有按如下方式加入软连接

ln -s /usr/lib64/libxml2.so   /usr/lib/libxml2.so

6.安装libcurl-devel ,libidn, automake

在php依赖包的libcurl-devel目录下

检查是否已安装:rpm-qa|grep libcurl-devel

libcurl-devel安装

rpm -ivh autoconf-2.63-5.1.el6.noarch.rpm

rpm -ivh automake-1.11.1-4.el6.noarch.rpm

rpm -ivh libidn-devel-1.18-2.el6.x86_64.rpm

rpm -ivh libcurl-devel-7.19.7-37.el6_4.x86_64.rpm

7.检查在/usr/lib 下mysql目录是否存在,不存在建软连接(已完成)

ln -s /usr/lib64/mysql   /usr/lib/mysql

8.安装zlib

zlib-1.2.3.tar.gz

CFLAGS="-O3-fPIC" ./configure --prefix=/usr/local/zlib/

make

注:需要将目录下的.a文件删掉重新编译才能使用。切记

make install

9.安装libpng

libpng-1.5.13.tar.xz

./configure --prefix=/usr/local/libpng

xz -d *.xz

make

make install

安装libpng-devel

rpm -ivh libpng-devel-1.2.49-1.el6_2.x86_64.rpm

10.安装jpeg

jpegsrc.v6b.tar.gz

./configure --prefix=/usr/local/jpeg

mkdir -p /usr/local/jpeg/bin

mkdir -p /usr/local/jpeg/man/man1/

make

make install

需要自己建立目录

查找jpeglib.h,没有装libjpeg-devel相关包

rpm -ivh libjpeg-turbo-devel-1.2.1-1.el6.x86_64.rpm

11.安装freetype

freetype-2.1.10.tar

./configure --prefix=/usr/local/freetype

make

make install

先安装vpx

rpm-ivh libvpx-1.3.0-5.el6_5.x86_64.rpm --nodeps

13.phpconfig ,按照实际情况修改/usr/local/apache2/bin/apxs,curl地址

php-5.6.21.tar

//MySQL安装指定到/usr/local/mysql版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/local/libxml2 --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect--enable-mbstring --with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap --without-pear--enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/

 

//MySQL默认安装rpm版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/local/libxml2 --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm--enable-force-cgi-redirect --enable-mbstring --with-mcrypt=/usr/local/libmcrypt/--with-openssl  --with-mhash--enable-pcntl --enable-sockets --enable-opcache=no --with-ldap-sasl--with-xmlrpc --with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext--enable-soap --without-pear --enable-bcmath --with-xpm-dir=/usr/lib64--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-vpx-dir=/usr/lib64/

 

//内存小于1G版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config --with-iconv-dir=/usr/local--with-freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/--with-png-dir=/usr/local/libpng/ --with-zlib=/usr/local/zlib/--with-libxml-dir=/usr/local/libxml2 --enable-xml --disable-rpath--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers--enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect--enable-mbstring --with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/--disable-fileinfo

 

//内存小于1G最终版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/ --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm--enable-force-cgi-redirect --enable-mbstring--with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/--disable-fileinfo

 

//内存大于1G最终版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/--with-png-dir=/usr/local/libpng/ --with-zlib=/usr/local/zlib/--with-libxml-dir=/usr/ --enable-xml --disable-rpath --enable-discard-path--enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex--enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring--with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/

 

make

make install

14.配置php.ini,拷贝到/usr/local/php/etc下,可以使用<?php phpinfo(); ?>检测路径

修改php.ini-development

max_execution_time =300

post_max_size =32M

max_input_time =300

date.timezone=PRC

always_populate_raw_post_data=-1

cp php.ini-development /usr/local/php/etc/php.ini

12.安装gd(php安装完成后再安装)

cd /root/software/php-5.6.21/ext/gd

执行:

/usr/local/php/bin/phpize(php安装完后增加扩展时使用)

#./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng --with-freetype=/usr/local/freetype

./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg--with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype

创建扩展,需要在/usr/local/php/etc/php.ini配置扩展

make

make install

然后打开/usr/local/php/etc/php.ini

找到;extension=/path/to/extension/msql.so增加一条:

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/gd.so

安装gettext

cd /root/software/php-5.6.21/ext/gettext

执行:

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

然后打开/usr/local/php/etc/php.ini

创建扩展,需要在/usr/local/php/etc/php.ini配置扩展

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/gettext.so

在/var/www/html/下,建立test.php文件测试扩展包是否正确

<?php

php info();

?>

php -r "phpinfo()"

15.启动hppted

service httpd start

安装zabbix

1.安装依赖包(net-snmp*.rpm) (已完成)

rpm -ivh elfutils-libelf-devel-0.152-1.el6.x86_64.rpm

rpm -ivh elfutils-devel-0.152-1.el6.x86_64.rpm

rpm -ivh lm_sensors-devel-3.1.1-17.el6.x86_64.rpm

rpm -ivh tcp_wrappers-devel-7.6-57.el6.x86_64.rpm

rpm -ivh file-devel-5.04-15.el6.x86_64.rpm

rpm -ivh popt-devel-1.13-7.el6.x86_64.rpm

rpm -ivh rpm-devel-4.8.0-37.el6.x86_64.rpm

rpm -ivh net-snmp-devel-5.5-49.el6.x86_64.rpm

2.安装zabbix

zabbix-3.0.2.tar.gz

./configure --prefix=/home/zabbix --enable-server --enable-agent --enable-proxy--with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl--with-libxml2

make

make install

3.创建zabbix用户及相应目录

//检查是否已创建完成zabbix用户

useradd zabbix

passwd zabbix

mkdir -p /var/log/zabbix/

chown -R zabbix:zabbix /var/log/zabbix

4.创建zabbix数据库

CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

5.创建mysql用户

grantall privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';

flush privileges;

6.在zabbix的database目录下导入数据库,数据文件

cd /root/software/zabbix-3.0.2/database/mysql

mysql -uroot -punicom zabbix < schema.sql;

mysql -uroot -punicom zabbix < images.sql;

mysql -uroot -punicom zabbix < data.sql;

7.需要关闭iptables

查看防火墙状态:

[root@centos6~]# service iptables status

iptables:未运行防火墙。

开启防火墙:

[root@centos6~]# service iptables start

关闭防火墙:

[root@centos6~]# service iptables stop

配置防火墙,开启80端口、3306端口

vi /etc/sysconfig/iptables #编辑防火墙配置文件

#Firewall configuration written by system-config-firewall

#Manual customization of this file is not recommended.

*filter

:INPUTACCEPT [0:0]

:FORWARDACCEPT [0:0]

:OUTPUTACCEPT [0:0]

-AINPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-AINPUT -p icmp -j ACCEPT

-AINPUT -i lo -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-AINPUT -j REJECT --reject-with icmp-host-prohibited

-AFORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

8.拷贝界面到www目录下

#根据自己设置的目录来

cp -rf /root/software/zabbix-3.0.2/frontends/php /var/www/html/zabbix

cp -rf /root/software/zabbix-3.0.2/frontends/php /usr/local/apache2/htdocs/zabbix(必须要设置,否则看不到)

service httpd restart

9.配置服务端服务

#根据实际安装路径来

cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_server/etc/rc.d/init.d/zabbix_server #服务端

cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_agentd/etc/rc.d/init.d/zabbix_agentd #客户端

chmod +x /etc/rc.d/init.d/zabbix_server #添加脚本执行权限

chmod +x /etc/rc.d/init.d/zabbix_agentd #添加脚本执行权限

chkconfig zabbix_server on #添加开机启动

10.查看zabbix_server.config配置是否正确

zabbix_server.config信息

vi /home/zabbix/etc/zabbix_server.conf

注:主要配置数据库信息

详细查阅:

http://blog.csdn.net/csolo/article/details/53083033

servicezabbix_server start  启动zabbix-server

11设置/etc/systemd/logind.confRemoveIPC=no

访问zabbix地址

http://ip/zabbix/setup.php

注:具体安装路径需以实际安装路径为准

欢迎关注“程序杂货铺”公众号,里面有精彩内容,欢迎大家收看^_^

Logo

更多推荐