一、系统环境
角色 | IP | 服务 | 端口 |
zabbix-server | 192.168.1.201 | mariadb5.5.52/Apache2.4.6/php 5.4.16/zabbix-server 3.2.4/zabbix-agent 3.2.4 | 3306\80\10051\10050 |
二、初始化系统
1、配置系统yum 163源
# cd /etc/yum.repos.d
#wget http://mirrors.163.com/.help/CentOS7-Base-163.repo # $releasever替换成相应版本 7
# yum clean all && yum makecache (yumrepolist)
2、配置zabbix yum源
#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
# more /etc/yum.repos.d/zabbix.repo
[zabbix] name=Zabbix Official Repository - $basearch baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 |
# yum repolist
3、关闭防火墙等
# systemctl disable firewalld && systemctl stop firewalld
# vi /etc/selinux/config
SELINUX=disabled |
三、安装 Mariadb
1、yum安装
# yum -y install mariadb*
2、自启
# systemctl enable mariadb
# systemctl start mariadb
3、配置mysql密码
# mysql_secure_installation
4、登入验证
# mysql -uroot -ppassword
四、安装Apache
1、yum安装httpd
#yum -y install httpd
2、自启
#systemctl enable httpd
#systemctl start httpd
五、安装PHP
1、yum安装php
# yum -y install php
#yum -y install php-mysql #用于让PHP程序使用MySQL数据库的模块
2、重启httpd,使php生效
# systemctl restart httpd
3、相关目录说明
/etc/httpd/conf.d/php.conf #被apache所读取的php配置文件
/etc/php.ini #php本身的配置文件
/etc/httpd/conf.modules.d/10-php.conf #apache 加载的php模块文件
4、测试php
# more/var/www/html/phpinfo.php
<?php phpinfo(); ?>
URL登入:http://192.168.1.201/phpinfo.php
六、安装Zabbix-Server
1、导入zabbix包(前面已经做过了)
#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
2、yum安装
#yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-sender
3、初始化数据库
#mysql -uroot -ppassword
mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by'zabbix'; //密码是 zabbix mysql> quit |
#cd /usr/share/doc/zabbix-server-mysql-3.2.4/
#zcat create.sql.gz | mysql -uzabbix -p zabbix #导入zabbix数据文件
#mysql -uzabbix -pzabbix
#验证zabbix库
# use zabbix;
# show tables;
4、配置zabbix-server
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password
# vi /etc/httpd/conf.d/zabbix.conf
<Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted
<IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai </IfModule> </Directory> |
5、自启
#systemctl restart zabbix-server
#systemctl enable zabbix-server
6、登入zabbix web界面并配置
# url: http://192.168.1.201/zabbix/setup.php
#默认账号密码: Admin zabbix
过程图:
注意:若有[][][]乱码,则按以下处理:
Win + R打开运行输入 fonts;
回车进入Windows字体目录,找到微软雅黑-常规字体,复制出来将文件名修改为msyh.ttf,然后上传到/usr/share/zabbix/fonts
上传成功以后,修改defines.inc.php的第45行,将graphfont改为msyh
# vim /usr/share/zabbix/include/defines.inc.php
完成图: