CentOS 编译安装 zabbix 3

版权声明:本文为原创文章,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。 https://blog.csdn.net/fgf00/article/details/78230031

一、依赖安装

环境:

系统环境:CentOS:7.2

zabbix版本:3.4.2

  • 安装依赖包
yum -y install mariadb mariadb-server php php-fpm php-cli php-common php-mcrypt php-pdo php-mysql mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp net-snmp-devel curl-devel OpenIPMI-devel gcc gcc-c++ autoconf libevent-devel libxml2-devel
  • PHP 版本问题

一定要注意:zabbix要求php版本必须是5.4以上,centos 7 php版本符合条件,centos 6需要升级PHP版本

[root@localhost install]# php -v
PHP 5.4.16 (cli) (built: Nov  6 2016 00:29:02) 
  • 配置php参数
sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/" /etc/php.ini 
sed -i "s/max_execution_time = 30/max_execution_time = 300/" /etc/php.ini 
sed -i "s/post_max_size = 8M/post_max_size = 32M/" /etc/php.ini
sed -i "s/max_input_time = 60/max_input_time = 300/" /etc/php.ini
  • 启动php-fpm
systemctl restart  php-fpm.service
systemctl enable  php-fpm.service

二、编译安装Nginx

zabbix官网下载地址:https://www.zabbix.com/download

nginx 官网下载地址:http://nginx.org/en/download.html

wget https://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.2/zabbix-3.4.2.tar.gz
wget http://nginx.org/download/nginx-1.12.1.tar.gz
  • 编译安装Nginx
tar zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure --prefix=/data/server/nginx
make -j32 && make install
  • 添加Nginx配置文件

vim /data/server/nginx/conf/nginx.conf

user  apache;
http {
    ......
    include vhosts/*.conf;
    ......
}

创建vhosts目录,vim /data/server/nginx/conf/vhosts/zabbix.conf

server{
    listen 8080;

    root /data/www/zabbix;

    location /
    {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ ^(.+.php)(.*)$ {
        fastcgi_split_path_info ^(.+.php)(.*)$;
        include fastcgi.conf;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  PATH_INFO          $fastcgi_path_info;
    }
    location ~* ^.+\.(ico|gif|jpg|jpeg|png|html|css|htm|bmp|js|svg)$ {
       root           /data/www/zabbix;
    }
}

启动Nginx

/data/server/nginx/sbin/nginx -t  # 配置检查
/data/server/nginx/sbin/nginx

三、配置数据库,配置zabbix

  • 设置mysql密码
systemctl restart  mariadb.service
mysqladmin -uroot password 'mysql_pass'  # -p123456 -p指定原密码
  • 创建zabbix数据库并设置权限
mysql -uroot -pmysql_pass -e "create database zabbix character set utf8;"
mysql -uroot -pmysql_pass -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
mysql -uroot -pmysql_pass -e "flush privileges;"
  • 导入zabbix数据库
tar zxvf zabbix-3.4.2.tar.gz
cd zabbix-3.4.2/database/mysql/
mysql -uzabbix -pzabbix zabbix < schema.sql 
mysql -uzabbix -pzabbix zabbix < images.sql 
mysql -uzabbix -pzabbix zabbix < data.sql
  • 配置mysql开机启动
systemctl enable mariadb.service
  • 复制zabbix站点文件
cp -rp zabbix-3.4.2/frontends/php/ /data/www/zabbix
chown -R apache.apache /data/www/zabbix/
  • 编译安装zabbix
./configure --prefix=/data/server/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-agent --with-openipmi --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --enable-ipv6 --with-openssl
make -j32 && make install

vim /etc/zabbix/zabbix_server.conf  # 确认连接数据库账户密码
LogFile=/tmp/zabbix_server.log  # 日志路径,38行
DBPassword=zabbix     # 119行
# 启动zabbix server
/data/server/zabbix/sbin/zabbix_server

四、页面配置zabbix**

地址:http://192.168.19.129:8080/setup.php

zabbix web页面 默认用户名及密码

用户名:Admin 密码:zabbix

zabbix web问题:点击下一步没反应

无法点击下一步。可能由于nginx用户和php-fpm用户不一致,修改php-fpm配置,使之一致

[root@localhost ~]# grep "user = " /etc/php-fpm.d/www.conf
user = apache
[root@localhost ~]# grep "user .*;" /data/server/nginx/conf/nginx.conf
user  apache;

五、安装zabbix_agent

yum -y install http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum -y install zabbix-agent

猜你喜欢

转载自blog.csdn.net/fgf00/article/details/78230031