centos 6.5 编译安装zabbix3.2


  注意zabbix需要 mysql、http、PHP为基础环境


1.安装mysql5.7.17


  1).解压:


 tar xvf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar



  2).移除已经安装的早期版本 

如果不移除的话,会提示有冲突,版本可能有所不同


      查看是否安装早期的版本,若有将其卸载


 rpm -qa | grep mysql

  

   yum -y remove mysql-libs-*


  3).安装rpm包,注意安装顺序

 

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

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

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

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

        rpm -ivh mysql-community-devel-5.7.17-1.el6.x86_64.rpm


  4).启动Mysql服务


[root@localhost ~]# service mysqld start

    Initializing MySQL database:                               [  OK  ]

    Installing validate password plugin:                       [  OK  ]

    Starting mysqld:                                           [  OK  ]


  5).修改管理员密码

  

     查看初始管理员密码:


        grep 'temporary password' /var/log/mysqld.log


       mysql -uroot -p    登录数据库


      修改密码,密码必须包含大写字母小写字母数字和符号


      mysql> alter user 'root'@'localhost' identified by 'Report@123';

      Query OK, 0 rows affected (0.05 sec)


      mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Report@123' WITH GRANT OPTION;  为      root用户授予所有权限


      mysql> FLUSH PRIVILEGES;


2.安装httpd-2.4.23


  1).检查是否安装httpd,若安装将其卸载,避免冲突


  rpm -q httpd

 

        rpm -e httpd --nodeps


  2)安装依赖环境


  yum -y install gcc gcc-c++


  3)安装http的依赖包


        1>安装apr


tar zxvf apr-1.5.2.tar.gz


cd apr-1.5.2


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


make && make install


2>安装apr-util


tar zxvf apr-util-1.5.4.tar.gz


cd apr-util-1.5.4


./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr


make && make install


3>安装pcre


tar zxvf pcre-8.38.tar.gz


cd pcre-8.38


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


make && make install



  4)安装httpd-2.4.23


1>安装


tar zxvf httpd-2.4.23.tar.gz -C /usr/local/


  cd /usr/local/httpd-2.4.23/


./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi --with-pcre=/usr/local/pcre   --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util


make && make install


2>优化执行路径


ln -s /usr/local/httpd/bin/* /usr/local/bin/


3>优化添加系统服务,并设为开机自启


cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd


chmod +x /etc/init.d/httpd


vim /etc/init.d/httpd  添加如下两行


#chkconfig: 2345 85 21

#description: Startup script for the Apache HTTP Server


chkconfig --add httpd


chkconfig httpd  on


chkconfig --list httpd


4>配置http并启动


vim /usr/local/httpd/conf/httpd.conf  修改如下:


#ServerName www.example.com:80


  ServerName www.example.com


httpd -t


service httpd start

3.安装PHP7


1)安装依赖环境


yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel pcre-devel curl curl-devel  libxslt-devel   libmcrypt-devel  gd-devel openssl openssl-devel  openldap  openldap-devel 


2)添加用户、同步时间


useradd -M -s /sbin/noloin  php


ntpdate 202.112.10.36

      3)安装依赖环境


tar zxvf libmcrypt-2.5.8.tar.gz 

 cd libmcrypt-2.5.8

  ./configure && make && make install 


4)编译安装PHP


tar zxvf php-7.0.14.tar.gz 


  cd php-7.0.14.tar.gz


cp -frp /usr/lib64/libldap* /usr/lib/

./configure --prefix=/usr/local/php7 --enable-fpm --enable-opcache --with-config-file-path=/usr/local/php7/etc  --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock    --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-static --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-freetype-dir --with-gd --with-jpeg-dir --with-xmlrpc --enable-mbstring --with-sqlite3 --with-curl --enable-ftp --with-mcrypt --with-openssl  --with-gettext  --with-ldap


make && make install 


5)创建php 、PHP-fpm配置

cp php-7.0.14/php.ini-production /usr/local/php7/etc/php.ini


cp /usr/local/php7/etc/php-fpm.d/www.conf.default  usr/local/php7/etc/php-fpm.conf



6)修改PHP-FPM的配置文件,将用户改为自己创建的用户


vim  usr/local/php/etc/php-fpm.conf


  #23 user = php

  #24 group = php


7)配置PHP-fpm开机自启动脚本


cp /root/php-7.0.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm


    chkconfig --add php-fpm


  chkconfig php-fpm on


        8)创建链接文件,查看版本以及启动情况


ln -s /usr/local/php7/sbin/php-fpm /usr/local/sbin/


ln -s /usr/local/php7/bin/* /usr/local/bin/


php -v


php-fpm -t


  

9)修改相应的PHP配置文件


vim /usr/local/php7/etc/php.ini


#368 max_execution_time = 300


#378 max_input_time = 300


#656 post_max_size = 16M


#924 date.timezone ="Asia/Shanghai"


10)重启使配置文件生效


/etc/init.d/php-fpm restart


11)配置httpd支持解析PHP

vim /usr/local/httpd/conf/httpd.conf


#155 LoadModule php7_module        modules/libphp7.so   配置http通过PHP解析PHP语言(默认有)


#385 AddType application/x-httpd-php .php  需要自己添加


#256  DirectoryIndex index.php index.html 注意修改


12)重启httpd ,并且创建测试页进行访问


/etc/init.d/httpd restart


vim /usr/local/httpd/htdocs/test.php

phpinfo();

?>


浏览器访问测试页:http://ip/test.php  能看到PHP的相关信息


4.安装zabbix3.2


1)查看基础环境是否安装


netstat -anplt | grep LISTEN


mysqld  -V


httpd  -v


php   -v


2)安装依赖环境


yum -y install curl curl-devel net-snmp   net-snmp-devel perl-DBI


  注意安装jdk依赖环境


3)创建用户


useradd -M -s /sbin/nologin zabbix


find / -name mysql_config    找到mysql_config的路径


4)安装


tar zxvf zabbix-3.2.7.tar.gz


cd zabbix-3.2.7


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


make && make install


5)创建zabbix数据库


mysql -u root -pReport@123  登录


mysql> create database zabbix character set utf8;


mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Zabbix@123';

mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';

 

mysql> flush privileges;


  mysql> exit 


    mysql> use zabbix #进入数据库 


    mysql> select database();#查看当前数据


6)数据按顺序导入zabbix数据库


mysql -u root -pReport@123 zabbix < /root/zabbix-3.2.7/database/mysql/schema.sql


mysql -u root -pReport@123 zabbix < /root/zabbix-3.2.7/database/mysql/p_w_picpaths.sql


mysql -u root -pReport@123 zabbix < /root/zabbix-3.2.7/database/mysql/data.sql


7)创建连接文件


  ln -s /usr/local/zabbix//etc/ /etc/zabbix


    ln -s /usr/local/zabbix/bin/* /usr/bin/


    ln -s /usr/local/zabbix/sbin/* /usr/sbin/


8)创建自启动脚本


cp zabbix-3.0.4/misc/init.d/fedora/core/zabbix_* /etc/init.d/


chmod 755 /etc/init.d/zabbix_*


vim /etc/init.d/zabbix_agentd 

  

    将BASEDIR=/usr/local 改为 BASEDIR=/usr/local/zabbix

   

    vim /etc/init.d/zabbix_server

     

      将BASEDIR=/usr/local 改为 BASEDIR=/usr/local/zabbix


    chkconfig zabbix_server on


    chkconfig zabbix_agentd on


9)修该配置文件


vim /etc/zabbix/zabbix_server.conf


      DBPassword=Zabbix@123 #数据库密码


    vim /etc/zabbix/zabbix_agentd.conf


      #91 Server=192.168.31.53


      #132 ServerActive=192.168.31.53


      #279  UnsafeUserParameters=1


10)配置web站点


cp -rf zabbix-3.2.7/frontends/php/ /usr/local/httpd/htdocs/zabbix


11)启动zabbix服务


/etc/init.d/zabbix_server start


    /etc/init.d/zabbix_agentd start


  注意zabbix_server zabbix_agentd 端口都要启动监听


12)在客户端以http方式访问


http://192.168.31.53/zabbix     用户名:admin  密码:zabbix


注意一步步进行不能有报错


           最后需要下载zabbix.conf.php文件,并把它放到zabbix服务器的/usr/local/httpd/htdocs/zabbix目录下,注意按提示进行



     此时部署完成