Centos7.6下zabbix4.0的安装配置

azhou 2020-06-12

系统环境
[x ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
准备环境

[root @ zabbix-server~] # systemctl disable firewalld.service

[root @ zabbix-server~] # systemctl stop firewalld.service

#关闭系统防火墙

[root @ zabbix-server~] # setenforce 0

[root @ zabbix-server~] # vim / etc / selinux / config
修改成:SELINUX = disabled
#关闭Selinux安全策略

首先配置lamp环境
分别安装 apache mysql php,并开启服务,设置自启,并检查有无错误.
[ ~]# yum install -y httpd
[ ~]# systemctl enable httpd
[ ~]# systemctl restart httpd

[ ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel
[ ~]# systemctl restart mariadb.service
[ ~]# systemctl enable mariadb.service

[ ~]# yum install -y php php-mysql php-fpm
[ ~]# systemctl restart php-fpm
[ ~]# systemctl enable php-fpm
测试lamp环境是否ok,在以上环节启动服务都没报错的情况下,在apache默认网站服务器下,输入以下测试内容,重启httpd,在网页上显示以下内容就表示ok.
[ ~]# vim /var/www/html/index.php

<?php
phpinfo();
?>

[ ~]# systemctl restart httpd
Centos7.6下zabbix4.0的安装配置
安装配置数据库
为了安全性,使用zabbix账户创建zabbix数据库
[ ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> insert into mysql.user(Host,User,Password) values("localhost","zabbix",password("mimimama"));
Query OK, 1 row affected, 4 warnings (0.01 sec)

MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to identified by "mimimama";
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
以上内容
mysql -u root -p
#用root登录,默认无密码,所以按两下回车即可
insert into mysql.user(Host,User,Password) values("localhost","zabbix",password("mimimama"));
#添加一个mysql用户zabbix并设置密码为mimimama
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
#创建zabbix数据库并且编码为utf8
flush privileges;
Query OK, 0 rows affected (0.00 sec)
#刷新数据库
grant all on zabbix. to identified by "mimimama";
Query OK, 0 rows affected (0.00 sec)
#grant 权限 on 数据库.
to 用户名@登录主机 identified by "密码";
flush privileges;
Query OK, 0 rows affected (0.00 sec)
#再刷新次数据库,使权限的设定生效
quit
#退出数据库
测试是否生效
[ ~]# cat /var/www/html/index.php
<?php

$link=mysql_connect(‘127.0.0.1‘,‘zabbix‘,‘mimimama‘);

if($link) echo "<h1>Success!!</h1>";

else echo "hahahahaha";

mysql_close();

?>
Centos7.6下zabbix4.0的安装配置
安装配置zabbix
如果要安装某个版本的话请自行在浏览器输入 http://repo.zabbix.com/zabbix/在里面找相关版本

安装zabbix所需要EPEL源和zabbix的yum源
[ ~]# yum install -y php-mbstring
[ ~]# yum install -y php-bcmath

或者是
rpm -ivh php-mbstring-5.4.16-42.el7.x86_64.rpm

rpm -ivh php-bcmath-5.4.16-42.el7.x86_64.rpm
接下来
[ ~]# rpm -ivh zabbix-web-4.4.0-1.el7.noarch.rpm
[ ~]# rpm -ivh zabbix-server-mysql-4.4.0-1.el7.x86_64.rpm
[ ~]# rpm -ivh zabbix-web-mysql-4.4.0-1.el7.noarch.rpm
RPM安装需要安装依赖包用yum本地直接安装。
[ ~]# cd /usr/share/doc/
[ doc]# ls |grep zabbix-server
zabbix-server-mysql-4.4.0

[ ~]# zcat /usr/share/doc/zabbix-server-mysql-4.4.0/create.sql.gz | mysql -uzabbix -p -h 127.0.0.1 zabbix
Enter password:

[ ~]#
修改时区,修改zabbix_server.conf的配置文件
[ ~]# cat /etc/php.ini | grep date.timezone
; http://php.net/date.timezone
;date.timezone =
[ ~]# vim /etc/php.ini
[ ~]# cat /etc/php.ini | grep date.timezone
; http://php.net/date.timezone
date.timezone = PRC

[ ~]# cat /etc/httpd/conf.d/zabbix.conf | grep date.timezone

php_value date.timezone Europe/Riga

[ ~]# vim /etc/httpd/conf.d/zabbix.conf
[ ~]# cat /etc/httpd/conf.d/zabbix.conf | grep date.timezone
php_value date.timezone Asia/Shanghai

[ zabbix]# vim /etc/zabbix/zabbix_server.conf
找到DBPassword取消注释并输入之前设置的密码,之前设置的是mimimama,不用加引号
Centos7.6下zabbix4.0的安装配置
设置服务开机自启动,重启服务,查看端口是否已开始监听
[ ~]# systemctl restart zabbix-server.service
[ ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

~]# systemctl restart httpd
接下来在浏览器中输入http://192.168.1.12/zabbix/
Centos7.6下zabbix4.0的安装配置Centos7.6下zabbix4.0的安装配置
mariadb端口号为3306,数据库名zabbix,用户zabbix
Centos7.6下zabbix4.0的安装配置
Centos7.6下zabbix4.0的安装配置
默认账号Admin,密码zabbix
Centos7.6下zabbix4.0的安装配置
修改语言的话右上角点击
Centos7.6下zabbix4.0的安装配置
然后修改为中文即可
Centos7.6下zabbix4.0的安装配置
如果直接输入ip地址的话访问的还是之前的hahahaha界面,如果想直接输入ip就访问zabbix监控的话只需要修改httpd.conf文件即可
[ zabbix]# whereis zabbix
zabbix: /usr/lib/zabbix /etc/zabbix /usr/share/zabbix
[ zabbix]# whereis zabbix
[ zabbix]# vim /etc/httpd/conf/httpd.conf
#编辑配置文件

DocumentRoot "/usr/share/zabbix"
#将DocumentRoot 之前的/var/www/html改为/usr/share/zabbix
[ zabbix]# systemctl restart httpd
#最后重启apache服务即可


相关推荐

89781738 / 0评论 2020-01-23