微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

基于LNMP搭建zabbix

环境准备

系统: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 即可

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述


在这里插入图片描述


在这里插入图片描述


在这里插入图片描述



修改zabbix页面语言

在这里插入图片描述


在这里插入图片描述


在这里插入图片描述


在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐