1.环境准备
1.安装nginx
2.部署php-fpm
3.部署数据库
4.部署zabbix服务端
2.部署nginx
配置nginx源
[root@m03 ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
##安装nginx
[root@m03 ~]# yum install nginx --enablerepo=nginx-stable
3.部署php
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release.noarch -y #webtatic 要求
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm #webtatic源
##方案2.[root@zabbix-server ~]# yum install epel-release -y
[root@zabbix-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
##安装php
yum install php72w-cli php72w-fpm php72w-gd php72w-mbstring php72w-bcmath php72w-xml php72w-ldap php72w mysqlnd -y
4.部署mariadb
1.安装数据库
[root@m03 ~]# yum install -y mariadb-server
2.配置数据库(删除无用的库和用户)
[root@m03 ~]# mysql_secure_installation
#进去之后选择删除没用的用户和库其他的都可以y
MariaDB [(none)]> select user,host from mysql.user ;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
| root | m03 |
+------+-----------+
4 rows in set (0.00 sec)
MariaDB [(none)]> show databases;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]>
###创建zabbix库
create database zabbix character set utf8 collate utf8_bin;
###创建zabbix用户密码为123456
grant all on zabbix.* to zabbix@'localhost' identified by '123456';
5.部署zabbix
1.安装zabbix yum源
rpm -Uvh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-
1.el7.noarch.rpm
#zabbix-release.....rpm zabbix yum源的配置文件
[root@m03 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/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://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
# 安装 zabbix-server
[root@m03 ~]# yum install -y zabbix-server zabbix-agent2
# zabbix 数据库导入数据
[root@m03 ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.13/create.sql.gz |mysql -uzabbix-p123456 zabbix
# zabbix 服务端 配置连接数据库
[root@m03 ~]# vim /etc/zabbix/zabbix_server.conf
[root@m03 ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
#修改后 zabbix 服务端开启的功能 (不用修改)
[root@m03 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
#启动 zabbix-server
root@m03 ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to
/usr/lib/systemd/system/zabbix-server.service.
[root@m03 ~]# systemctl start zabbix-server.service
5.1zabbix前端页面准备
#使用源码包
tar xf zabbix-5.0.13.tar.gz
cd zabbix-5.0.13/
mv ui/* /code/zabbix/
chown -R nginx.nginx /code/zabbix/
#web页面安装
6.nginx配置文件
[root@zabbix ~]# egrep '^$|^#' /etc/nginx/conf.d/zabbix.conf
[root@zabbix ~]# cat /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name www.zabbix.cn;
root /code/zabbix;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
7.php配置文件
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
8.数据库已经在安装时候已经完成测试就行
mysql -uroot -p123
mysql -uzabbix -p123456
use 进入库中看是否表导进去了
show tables;
9.zabbix配置文件
[root@zabbix ~]# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartVMwareCollectors=5
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
网友评论