centos 6.4 下安装配置 zabbix 3.2 的过程 。
由于工作需要 。安装最新版本的zabbix 3.2 作为公司监控使用 。
一、环境
一台电脑IP地址:10.2.2.1
(参考:http://cuchadanfan.blog.51cto.com/9940284/1663708)
安装php 环境
yum install -y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring //rpm包搭建lamp环境 如果mysql 已经安装 则mysql 包可忽略
yum install -y zabbix zabbix-agent zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql net-snmp-devel
安装发现 zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql 这些安装包失败
于是转向www.zabbix.com 查看相关的下载文件和文挡 :
继续安装:
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.3-1.el6.x86_64.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-java-gateway-3.2.3-1.el6.x86_64.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-proxy-mysql-3.2.3-1.el6.x86_64.rpm
完成后发现无法正常启动 于是继续安装 :
wget http://http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-3.2.3-1.el6.noarch.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-3.2.3-1.el6.noarch.rpm
安装报错 ,提示缺少依赖包 ,于是改为:
yum --enablerepo=zabbix-deprecated install zabbix-server-mysql
yum --enablerepo=zabbix-deprecated install zabbix-web-mysql
yum --enablerepo=zabbix-deprecated install zabbix-web
二 :安装mysql 并设置/etc/my.cnf
[mysql] //增加mysql的字符集避免在浏览器上进入zabbix出现乱码
default-character-set = utf8
[mysqld] //同上
character_set_server = utf8
然后导入文件:
mysql -uroot -proot
mysql> create database zabbix character set utf8; #创建zabbix数据库,并设定编码格式为utf8
[root@zabbix-195 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz|mysql -uroot -proot zabbix #导入库文件
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; #授权
先创建ZABBIX数据库,再导入库文件,最后再授权,按这个顺序,要不然会报错。
启动服务:
/etc/init.d/zabbix-server start
/etc/init.d/zabbix-agent start
/etc/init.d/httpd start
其中httpd 报错解决方法:启动apache遇到错误:httpd: Could not reliably determine the server's fully qualified domain name
编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
httpd.conf 文件可通过 find / -name httpd.conf 找到 。
三 :通过WEB页面设置ZABBIX
cp /usr/share/doc/zabbix-web-3.2.0/httpd22-example.conf /etc/httpd/conf.d/zabbix.conf #把ZABBIX的配置文件放到HTTPD加载的目录中
/etc/init.d/httpd restart #重新启动HTTPD使配置文件生效
在浏览器中输入http://192.168.44.195/zabbix,报500的错误,
查看httpd日志:
PHP Parse error: syntax error, unexpected ‘[‘ in /usr/share/zabbix/index.php on line 29
报PHP错误,查找资料得知,是PHP版本太低了导致。
四 :升级PHP为5.6版本
追加CentOS 6.6的epel及remi源。
# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
以下是CentOS 7.0的源。
# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用yum list命令查看可安装的包(Packege)。
# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
安装PHP5.6
# yum -y install --enablerepo=remi
--enablerepo=remi-php56 php php-opcache php-devel php-mbstring
php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug
php-pecl-xhprof
其中遇到问题 :cannot retrieve metalink for repository epel. please verify its path and try again
解决方法 :
允许remi repository
vi /etc/yum.repos.d/remi.repo
编辑[remi]下的enabled选项从0设为1
[remi] name=Les RPM de remi pour Enterprise Linux 6 - $basearch #baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/ mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
至此,安装完成。
安装完运行yum报错:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
解决办法:
vi /etc/yum.repos.d/epel.repo
编辑[epel]下的baseurl前的#号去掉,mirrorlist前添加#号。正确配置如下:
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority
enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
再运行
yum makecache
还是报错:
最后运行 yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
然后成功 。
参考文献:
https://www.zabbix.com/forum/archive/index.php/t-55635.html
https://teddysun.com/153.html
http://www.2cto.com/os/201201/117797.html
http://www.rfyy.net/archives/1742.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?