zabbix5.0+nginx安装步骤

zabbix5.0+nginx安装步骤

zabbix官网:https://www.zabbix.com/cn/download
过程是基于centos7操作的。如果直接使用国内的yum安装可能会出现难以解决的错误。

1: yum 安装zabbix-server zabbix-agent

1.1 配置yum源
# 配置基础镜像源(这里选择阿里云的镜像源)
mkdir /etc/yum.repos.d/repo.bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo.bak	# 备份当前的yum源
# 下载阿里云镜像源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 安装zabbix官方yum源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

# 将zabbix官方yum源 修改为阿里云yum源,如下为修改后,可直接复制粘贴
vim zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
1.2: 安装zabbix-server与zabbix-agent
yum -y install zabbix-server-mysql zabbix-agent
1.3 安装zabbix前端web服务
yum -y install centos-release-scl
yum -y install zabbix-web-mysql-scl zabbix-nginx-conf-scl
# 如果安装失败则执行如下命令
yum -y install rh-php72*

2: MySQL数据库安装配置

2.1: 配置MySQL yum源
# 安装MySQL官方yum源
rpm -Uvh https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
# 修改为国内yum源,只保留如下,其余可以删除
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2.2: 安装MySQL
# 使用yum源安装,
yum -y install mysql mysql-server

# 或者直接把rpm包下载到本地进行安装,rpm包名称如下
# 国内MySQL5.7下载地址:https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/
mysql-community-client-5.7.34-1.el7.x86_64.rpm
mysql-community-libs-5.7.34-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
mysql-community-server-5.7.34-1.el7.x86_64.rpm
mysql-community-common-5.7.34-1.el7.x86_64.rpm
2.3:配置MySQL
>> systemctl start mysqld
>> grep password /var/log/mysql.log #取出初始化密码
>> mysql -p #初始化密码
mysql> set password = password("123qqq...A");
mysql> set global validate_password_length=6;
mysql> set global validate_password_policy=0;
mysql> set password = password("123456");
mysql>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'zabbix';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
msyql> exit

vim /etc/my.cnf
validate_password_length=6
validate_password_policy=0

systemctl restart mysqld
2.4:往mysql导入zabbix服务信息
>> zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

3: zabbix_server配置

3.1:为zabbix_server服务器配置连接数据库
>> vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBUser=zabbix
DBPassword=zabbix
DBName=zabbix
DBPort=3306
3.2: nginx端配置
# nginx配置1
# 取消注释并设置listen和server_name
vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf

listen 80;
server_name example.com; # server_name可以不用设置 
# nginx配置2
# 注释listen,server_name,root

vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf

    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /opt/rh/rh-nginx116/root/usr/share/nginx/html;

        # Load configuration files for the default server block.
#        include      /etc/opt/rh/rh-nginx116/nginx/default.d/*.conf;

....
}
3.3: php配置
# 配置PHP,将nginx添加到listen.acl_users指令
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

listen.acl_users = apache,nginx

# 设置时区
php_value[date.timezone] = Asia/Shanghai

4: 启动

systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

5: zabbix agent端配置

[root@vm63 ~]# grep -vE '^($|#)' /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.100.62	 # zabbix server端IP
ServerActive=192.168.100.62	 # zabbix server端IP
Hostname=vm62		 #本机主机名
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UnsafeUserParameters=1	# 1为开启自定义模板
[root@vm63 ~]# systemctl start zabbix-agent.service

6: 访问

http://ip/

zabbix5.0+nginx安装步骤_第1张图片
zabbix5.0+nginx安装步骤_第2张图片
zabbix5.0+nginx安装步骤_第3张图片
zabbix5.0+nginx安装步骤_第4张图片
zabbix5.0+nginx安装步骤_第5张图片

你可能感兴趣的:(zabbix)