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/

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是在 CentOS 7 上安装 Zabbix 6.0、Nginx、MySQL 8、PHP 7.4 的步骤: 1. 安装 EPEL 和 Remi 源: ``` yum install -y epel-release rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm ``` 2. 安装 Nginx: ``` yum install -y nginx systemctl start nginx systemctl enable nginx ``` 3. 安装 PHP 7.4: ``` yum install -y php74-php-fpm php74-php-mysqlnd php74-php-xmlrpc php74-php-gd php74-php-intl php74-php-mbstring php74-php-soap php74-php-xml php74-php-json php74-php-zip systemctl start php74-php-fpm systemctl enable php74-php-fpm ``` 4. 安装 MySQL 8: ``` rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm yum install -y mysql-community-server systemctl start mysqld systemctl enable mysqld ``` 5. 配置 MySQL: ``` mysql_secure_installation ``` 6. 创建 Zabbix 数据库: ``` mysql -u root -p CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost'; FLUSH PRIVILEGES; EXIT; ``` 7. 导入 Zabbix 数据库: ``` cd /usr/share/doc/zabbix-server-mysql-6.0.0/ zcat create.sql.gz | mysql -u zabbix -p zabbix ``` 8. 安装 Zabbix Server 和 Agent: ``` yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent ``` 9. 配置 Zabbix: ``` vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=password ``` 10. 启动 Zabbix Server 和 Agent: ``` systemctl start zabbix-server zabbix-agent systemctl enable zabbix-server zabbix-agent ``` 11. 配置 Nginx: ``` vi /etc/nginx/conf.d/zabbix.conf server { listen 80; server_name localhost; root /usr/share/zabbix; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php74-php-fpm/zabbix.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ``` 12. 重启 Nginx: ``` systemctl restart nginx ``` 13. 打开浏览器,输入服务器 IP 地址,进入 Zabbix Web 界面,按照提示进行 Zabbix 配置即可。 注意:以上步骤仅供参考,具体操作根据实际情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值