一、环境准备
环境描述
- PHP:72
- Nginx 1.16
- MySQL 8.0
- Zabb
文章来源(Source):https://www.dqzboy.com ix 4.4
1.1:设置阿里镜像源
[root@zabbix-server ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@zabbix-server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@zabbix-server ~]# yum install epel-release
1.2:关闭SELINUX
[root@zabbix-server ~]# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@zabbix-server ~]# setenforce 0
[root@zabbix-server ~]# getenforce
Permissive
1.3:安装常用软件
[root@zabbix-server ~]# yum -y install bash-completion
[root@zabbix-server ~]# yum -y install bash-completion-extras
[root@zabbix-server ~]# yum -y install vim net-tools wget gcc gcc-devel lrzsz ntp make patch openssl openssl-devel libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed libtool zlib zlib-devel pcre pcre-devel
1.4:同步互联网时间
[root@zabbix-server ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@zabbix-server ~]# ntpdate time1.aliyun.com
[root@zabbix-server ~]# echo "*/5 * * * * ntpdate time1.aliyun.com &> /dev/null && hwclock -w" >> /var/spool/cron/root
[root@zabbix-server ~]# systemctl restart crond
1.5:放通zabbix监听端口
#放开端口
[root@zabbix-server ~]# firewall-cmd --permanent --zone=public --add-port=10050/tcp
[root@zabbix-server ~]# firewall-cmd --permanent --zone=public --add-port=10051/tcp
[root@zabbix-server ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
#使其规则生效
[root@zabbix-server ~]# firewall-cmd --reload
#查看端口是否放开
[root@zabbix-server ~]# firewall-cmd --list-port
10050/tcp 10051/tcp 80/tcp
二、部署Nginx
2.1:安装
- 使用RPM包进行安装
[root@zabbix-server ~]# mkdir /soft
[root@zabbix-server ~]# cd /soft/
[root@zabbix-server soft]# wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.16.1-1.el7.ngx.x86_64.rpm
[root@zabbix-server soft]# rpm -ivh nginx-1.16.1-1.el7.ngx.x86_64.rpm
[root@zabbix-server ~]# nginx -v
nginx version: nginx/1.16.1
2.2:启动
[root@zabbix-server ~]# systemctl start nginx
[root@zabbix-server ~]# systemctl enable nginx
[root@zabbix-server ~]# systemctl status nginx
2.3:访问

三、部署MySQL
- 安装新版MySQL8.0版本
3.1:下载YUM源
[root@zabbix-server ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
3.2:安装YUM源
[root@zabbix-server ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
3.3:安装服务端
# 查看 mysql server
[root@zabbix-server ~]# yum repolist enabled | grep "mysql.*-community.*"
[root@zabbix-server ~]# yum repolist all | grep mysql
# 安装
[root@zabbix-server ~]# yum install mysql-community-server
3.4:启动服务
[root@zabbix-server ~]# systemctl start mysqld.service
[root@zabbix-server ~]# systemctl enable mysqld.service
[root@zabbix-server ~]# systemctl status mysqld.service
3.5:密码配置
3.5.1:查看登陆密码
[root@zabbix-server ~]# cat /var/log/mysqld.log | grep 'password'
3.5.2:登陆
[root@zabbix-server ~]# mysql -uroot -p
- 到这里 MySQL 就完全安装完成了
3.5.3:重置密码
# 密码验证策略低要求
mysql> set global validate_password.policy=0; (0或LOW代表低级)
# 密码至少要包含的小写字母个数和大写字母个数
mysql> set global validate_password.mixed_case_count=0;
# 密码至少要包含的数字个数。
mysql> set global validate_password.number_count=0;
# 密码至少要包含的特殊字符数
mysql> set global validate_password.special_char_count=0;
# 密码长度
mysql> set global validate_password.length=4; #8.0最小长度为4
# 再次设置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'dqz123';
3.6:创建用户和数据库
# 创建数据库
[root@zabbix-server ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
# 创建zabbix账号;MySQL8.0的账号身份验证和MySQL5.7不同
mysql> create user zabbix@localhost identified with mysql_native_password by 'dqz123';
# 授权
mysql> grant all privileges on zabbix.* to zabbix@localhost;
四、部署PHP
4.1:安装
[root@zabbix-server ~]# yum install epel-release
[root@zabbix-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@zabbix-server ~]# yum install php72w-fpm php72w-opcache
4.2:配置
[root@zabbix-server ~]# vim /etc/php.ini
368 max_execution_time = 300 //默认30,Zabbix要求为300
378 max_input_time = 300 //默认60
385 max_input_vars = 10000 //去除注释,默认1000改为10000
389 memory_limit = 128M //内存限制
656 post_max_size = 16M //默认8M改为16M
877 date.timezone = Asia/Shanghai //去除注释,默认空,更为为上海时区
# 修改用户
[root@zabbix-server ~]# vim /etc/php-fpm.d/www.conf
8 user = nginx
10 group = nginx
[root@zabbix-server ~]# chown -R nginx. /var/lib/php
4.3:启动
[root@zabbix-server ~]# systemctl start php-fpm
[root@zabbix-server ~]# systemctl enable php-fpm
五、安装Zabbix-server
5.文章来源(Source):https://www.dqzboy.com 1:添加Zabbix镜像源
[root@zabbix-server ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[root@zabbix-server ~]# yum clean all
- 注:安装时有可能被墙导致安装失败,可替换官方源地址,将官方地址改为清华源的地址
[root@zabbix-server ~]# vim /etc/yum.repos.d/zabbix.repo
# 末行模式输入以下进行替换
:%s#http://repo.zabbix.com/zabbix/4.4/rhel/7/#https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/#g
5.2:安装zabbix-server
#安装服务端,前端,和agent
[root@zabbix-server ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-nginx-conf
5.3:配置zabbix数据库
#导入数据
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: //zabbix用户密码
#编辑配置文件
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
91 DBHost=localhost //去除注释
100 DBName=zabbix //数据库名称
116 DBUser=zabbix //用户
124 DBPassword=123456 //去除注释,输入数据库用户zabbix的密码
# 以下解决报警:Zabbix discoverer processes more than 75% busy问题
189 StartPollers=12 //去除注释,增加初始化进程,默认5
244 StartDiscoverers=5 //去除注释,增加discovery进程数量,默认1
5.4:启动Zabbix Server
[root@zabbix-server ~]# systemctl start zabbix-server.service
[root@zabbix-server ~]# systemctl enable zabbix-server.service
[root@zabbix-server ~]# systemctl status zabbix-server.service
5.5:检查日志是文章来源(Source):https://www.dqzboy.com 否有报错
[root@zabbix-server ~]# more /var/log/zabbix/zabbix_server.log
5.6:配置zabbix-web
- 将nginx默认调用的外部配置文件重命名,这样就直接调用zabbix的配置文件了
[root@zabbix-server ~]# cd /etc/nginx/conf.d/
[root@zabbix-server conf.d]# mv default.conf{,_bak}
- zabbix.conf配置文件内容如下
server {
# listen 80;
# server_name example.com;
root /usr/share/zabbix;
index index.php;
location = /favicon.ico {
log_not_found off;
}
location / {
try_files $uri $uri/ =404;
}
location /assets {
access_log off;
expires 10d;
}
location ~ /\.ht {
deny all;
}
location ~ /(api\/|conf[^\.]|include|locale) {
deny all;
return 404;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm/zabbix.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix;
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
5.7:重新启动服务
[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent nginx php-fpm
[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent nginx php-fpm
5.8:访问页面
六、zabbix页面配置
6.1:前端设置
- 默认登入用户密码:Admin/zabbix
必须 注册 为本站用户, 登录 后才可以发表评论!