liukun2009 发表于 2019-1-20 12:01:05

Zabbix3.0LTS安装

  基础环境:
  Nginx:1.8.1
  Mysql:5.6.29
  PHP:5.5.30(zabbix_3.0要求PHP版本在5.4以上)
  

  一、安装LNMP
  1、安装过程在此不再叙述,请参考其他文章
  2、注意:PHP编译时,须带上--with-mysqli=mysqlnd和--with-gettext支持Zabbix
  

  二、安装Zabbix
  1、提示:官方安装文档:https://www.zabbix.com/documentation/3.0/manual/installation/install
  2、下载源码包:
  shell>wget http://www.zabbix.com/download.php
  

  3、yum安装基础环境
  shell>yum install mysql-dev gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xm
  

  4、添加zabbix用户
  shell>useradd zabbix -s /sbin/nologin
  

  5、编译安装
  shell>tar xf zabbix-3.0.1.tar.gz;cd zabbix-3.0.1
  shell>./configure --prefix=/opt/app/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  shell>make install
  参数说明
  ―prefix=为指定安装目录
  ―enable-server为安装zabbix服务端程序
  ―enable-agent为安装agent程序
  ―with-mysql为使用mysql数据库
  ―enable-ipv6为启用ipv6支持
  ―with-net-snmp为启用snmp支持
  ―with-libcurl为启用curl
  ―with-libxml2编译xml模块,主要用于监控vm虚拟机
  

  6、创建MySQL库和zabbix读写账户
  mysql>create database zabbix character set utf8 collate utf8_bin;
  mysql>grant all privileges on zabbix.* to zabbix@'%' identified by '';
  mysql>flush privileges;
  

  7、进入到MySQL数据目录,按照顺序导入数据到zabbix库
  shell>cd /opt/src/zabbix-3.0.1/database/mysql/
  mysql>mysql -uroot -pzabbix < schema.sql
  mysql>mysql -uroot -pzabbix < images.sql
  mysql>mysql -uroot -pzabbix < data.sql
  

  8、增加和修改zabbix配置文件
  shell>vim /opt/app/zabbix/etc/zabbix_server.conf
  DBName=zabbix #数据库名称
  DBUser=zabbix #数据库用户名
  DBPassword= #数据库密码
  DBPort= #数据库端口
  ListenIP=0.0.0.0
  AlertScriptsPath=/opt/app/zabbix/alertscripts #zabbix运行脚本存放目录
  

  9、启动zabbix server
  shell>/opt/app/zabbix/sbin/zabbix_server
  如有报错,查找zabbix错误日志
  

  10、设置PHP.ini参数

  shell>vim $PHP_PATH/php.ini 主要为下面几个参数
  PHP option post_max_size 16M
  PHP option max_execution_time 300
  PHP option max_input_time 300
  PHP time zone Asia/Shanghai
  

  11、启动PHP
  shell>service php-fpm start
  

  12、配置Zabbix Web环境
  shell>cd zabbix-3.0.1/frontends/
  shell>cp -rf php /data/wwwroot/zabbix.xxx.com
  shell>cd /data/wwwroot/zabbix.xxx.com/conf/
  shell>chown www.www -R zabbix.xxx.com; chmod 755 -R zabbix.xxx.com
  

  

  13、配置Zabbix的Nginx虚拟主机
server
{
      listen 80;
      server_name zabbix.XXX.com;
      index index.php index.html;
      root /data/wwwroot/zabbix.XXX.com;
                location ~ .*\.(php|php5)?$
                {      
                  fastcgi_passunix:/tmp/php-cgi.sock;
                  #fastcgi_pass127.0.0.1:9000;
                  fastcgi_index index.php;
                  include fcgi.conf;
                }
}  

  14、确认php、nginx、mysql,已经启动。浏览器中打开zabbix.xxx.com页面,根据提示,一步步配置Zabbix
  

15、设置中文支持
A> 找到/data/wwwroot/zabbix.xxx.com/include/locales.inc.php文件,找到55行,将flase改为true,如:'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
B> 登录进去,点击右上角人形图标设置中文。


16、因修改了语言,图形会出现乱码,做如下修改
A:下载微软雅黑字体,将wryh.ttf上传至/data/wwwroot/zabbix.xxx.com/fonts/目录下
  B>找到:/data/wwwroot/zabbix.xxx.com/include/defines.inc.php
C>define('ZBX_FONT_NAME', 'wryh'); #第45行
D>define('ZBX_FONT_NAME', 'wryh'); #第93行
  

  17、安装完成



页: [1]
查看完整版本: Zabbix3.0LTS安装