环境准备
系统:centos 7
IP:10.10.10.4
关闭防护墙、selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
安装zabbix、MySQL
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost ~]# ls
zabbix_Aliyun.repo
[root@localhost ~]# cat zabbix_Aliyun.repo
# 以下是我安装zabbix所用的阿里云yum源
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.2/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.2/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-agent zabbix-web-mysql mariadb-server
上传或下载Nginx源码包,也可直接下载Nginx
1、直接下载Nginx
# 下载epel源
[root@localhost ~]# yum -y install epel-release.noarch
[root@localhost ~]# yum -y install nginx php-fpm php
2、源码包编译安装----也是本次我所使用的nginx安装方式
# 下载编译依赖包以及PHP
[root@localhost ~]# yum -y install wget gcc gcc-c++ zlib-devel pcre-devel make php-fpm php
# 下载nginx源码包
[root@localhost ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
# 解压并进入源码包
[root@localhost ~]# tar zxf nginx-1.18.0.tar.gz
[root@localhost ~]# cd nginx-1.18.0
# 检测编译环境及编译安装
[root@localhost ~]# ./configure && make && make install
启动数据库创建zabbix库并授权zabbix用户
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
MariaDB [(none)]> create database zabbix charset utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on *.* to zabbix@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
修改zabbix默认字体
# 字体文件可以从Windows电脑上拷贝一个简体的字体文件到电脑桌面,然后上传。
# Windows字体文件目录:C:\Windows\Fonts
[root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
[root@localhost fonts]# ls
graphfont.ttf simhei.ttf
[root@localhost fonts]# mv simhei.ttf graphfont.ttf
mv: overwrite ‘graphfont.ttf’? y
###### 修改zabbix-server配置文件连接数据库
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
91 DBHost=localhost # 数据库授权的连接方式 可以是IP
116 DBUser=zabbix # 数据库授权的用户
124 DBPassword=zabbix # 数据库授权zabbix用户的密码
初始化zabbix
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.2.8/create.sql.gz | mysql -uzabbix -pzabbix zabbix
修改时区
[root@localhost ~]# vim /etc/php.ini
878 date.timezone = PRC
修改Nginx配置文件
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
43 location / {
44 root html;
45 index index.php index.html index.htm;
46 }
......
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
70 include fastcgi_params;
71 fastcgi_buffer_size 128k;
72 fastcgi_buffers 4 256k;
73 fastcgi_busy_buffers_size 256k;
74 }
# 保存退出并启动nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
将zabbix页面文件链接到Nginx网站根目录
[root@localhost ~]# ln -s /usr/share/zabbix/ /usr/local/nginx/html/
启动zabbix
[root@localhost ~]# systemctl start zabbix-server zabbix-agent php-fpm
浏览器登陆页面
浏览器输入http://10.10.10.6/zabbix 注:10.10.10.6是我本机IP
******显示以上报错我们需要去修改PHP文件
[root@localhost ~]# vim /etc/php.ini
....
384 max_execution_time = 300
....
394 max_input_time = 300
....
672 post_max_size = 16M
# 修改完毕保存退出并重启PHP以及Nginx
[root@localhost ~]# systemctl restart php-fpm
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
注:此处报错可能不止三处,报什么错就根据报错提示修改。 比如 PHP option "post_max_size" 8M 16M Fail 此处报错,PHP文件里是 post_max_size = 8M ,将其修改为提示里的 16M 即可