centos7 nginx安装 Zabbix

参考官方网址:

https://www.zabbix.com/download

1、安装php

使用yum直接安装php,php-gd,php-mysql,php-fpm php-mbstring php-xml 

# yum -y install php php-gd php-mysql php-fpm php-mbstring php-xml

配置php

编辑/etc目录下php.ini文件

post_max_size = 16M

max_execution_time = 300

max_input_time = 300

date.timezone = "Asia/Dubai"

开机启动php-fpm

# systemctl enable php-fpm.service

# systemctl start php-fpm

2、安装mysql

安装完成后创建库,用户并授权

# create database zabbix character set utf8 collate utf8_bin;

# create user ‘username’@‘host’ identified by ‘password’;

# grant all privileges on . to ‘username’@’%’ with grant option;

# flush privileges;

注意:如果mysql版本为8.0,Zabbix 4.0连接数据库,中间遇到很多问题,比如由于MySQL 8.0默认使用了新的密码验证插件caching_sha2_password,而之前的PHP版本中所带的mysqlnd无法支持这种验证。

解决方案:

一、升级PHP支持MySQL 8.0的新验证插件,目前PHP 7.2.8支持新的密码验证插件caching_sha2_password,可以直接连接MySQL 8.0。我们通过phpinfo()函数了解当前安装的PHP 7.2.8支持密码验证插件caching_sha2_password。

二、在MySQL 8.0中修改使用caching_sha2_password插件的账户的加密方式为mysql_native_password,这样先前版本的PHP就可以连接使用了,如下:

#查看用户加密方式
select user,host,plugin from mysql.user;

#修改用户认证方式
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password  BY 'password';

导入数据(使用 MySQL 来导入 Zabbix server 的初始数据库 schema 和数据)

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p Zabbix

3、安装nginx

yum -y install epel-release

yum -y install nginx

配置nginx

编辑/etc/nginx目录下nginx.conf文件

#开启gzip压缩
gzip on;

#开启后可将”.conf”文件结尾的配置文件都放此目录下
include /etc/nginx/conf.d/*.conf;

编辑zabbix.conf文件

server {
	listen       80;
	server_name  _;

	location  / {
		root /usr/share/zabbix;
		index index.php  index.html;
	}
	
	location ~ \.php$ {
	    root           /usr/share/zabbix;
	    fastcgi_pass   127.0.0.1:9000;
	    fastcgi_index  index.php;
	    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	    fastcgi_buffers 8 128k;
	    fastcgi_buffer_size 128k;
	    include	/etc/nginx/fastcgi_params;
	}
	
	error_page 404 /404.html;
	    location = /40x.html {
	}

	error_page 500 502 503 504 /50x.html;
	    location = /50x.html {
	}
}

4、安装Zabbix

1)添加 Zabbix 软件仓库

# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

2)安装Zabbix Server

yum -y install zabbix-server-mysql  zabbix-web-mysql

3)配置zabbix前端/etc/httpd/conf.d/zabbix.conf

php_value date.timezone Aisa/Shanghai

4)配置Zabbix Server所使用的数据库

编辑/etc/zabbix/zabbix_server.conf文件以下内容

DBHost=localhost  数据库地址

DBName=zabbix  数据库名字

DBUser=zabbix  数据库用户名

DBPassword=<password>  数据库用户密码

DBPort=3306 数据库端口

开机启动Zabbix Server进程并启动zabbix server

# systemctl enable zabbix-server

# systemctl start zabbix-server

6、测试zabbix

http://ip/setup.php

7、安装Zabbix Agent

# yum install zabbix-agent

配置Zabbix Agent

修改/etc/zabbix下zabbix_agentd.conf文件

Server=Server端IP地址

ServerActive=Server端IP地址

Hostname=主机名(此名称非常重要,请勿乱填,因为后面在web上添加主机时需要这个名字)

设置Zabbix Agent 开机启动并启动

# systemctl enable zabbix-agent

# systemctl start zabbix-agent

8、Zabbix4.0 Web管理界面中文乱码解决方法

1)复制本地电脑C:\Windows\Fonts\simkai.ttf(楷体)上传到zabbix服务器网站目录的fonts目录下

2)zabbix网站目录fonts目录查找如下:

[root@ecs-5c78-0001 ~]# whereis zabbix 或者 find / -name graphfont.ttf 直接找到zabbix字体文件夹

zabbix: /usr/lib/zabbix /etc/zabbix /usr/share/zabbix

[root@ecs-5c78-0001 ~]# cd /usr/share/zabbix/fonts/ 或者 cd /usr/share/zabbix/assets/fonts/

[root@ecs-5c78-0001 fonts]# ll

total 11528

lrwxrwxrwx 1 root root       33 Jan 14 15:24 graphfont.ttf -> /etc/alternatives/zabbix-web-font

3)graphfont.ttf是zabbix默认字符集,现在需要把PC拿到的字体上传到/usr/share/zabbix/fonts/或者 cd /usr/share/zabbix/assets/fonts/这个目录下,可以安装

4)删除默认软链接的字符集,指向新安装的字符集

[root@ecs-5c78-0001 alternatives]# rm -f /etc/alternatives/zabbix-web-font

[root@ecs-5c78-0001 alternatives]# ln -s /usr/share/zabbix/fonts/simkai.ttf  /etc/alternatives/zabbix-web-font

或者

[root@ecs-5c78-0001 alternatives]# ln -s /usr/share/zabbix/assets/fonts/simkai.ttf  /etc/alternatives/zabbix-web-font

查看

5)重启zabbix-server服务

[root@ecs-5c78-0001 alternatives]# systemctl restart zabbix-server

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不忘丶初衷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值