NGINX:
#创建nginxyum仓库
vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
#清空缓存
yum clean all
#安装依赖
yum -y install openssl-devel libxml2 libxml2-devel net-snmp-devel libevent-devel java-devel net-snmp-devel libcurl-devel
#安装nginx
yum install nginx -y
#查看版本
nginx -v
MySQL:
上传MySQL的rpm包到/opt:
在百度网盘 提取码:asje
依次安装:
rpm -ivh mysql-community-common-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.32-1.el7.x86_64.rpm
开启mysql
systemctl enable mysqld --now
查看版本:
mysql -V
如出现以下错误:
错误
yum -y remove mysql-lib mariadb
删除后重新装mysql-community-libs-8.0.32-1.el7.x86_64.rpm
优化MySQL
查看MySQL初始密码(mysql8.0版本后都有初始密码)
grep "password" /var/log/mysqld.log | awk '{print $NF}'
mysqladmin -uroot -p password
#写刚刚查看的密码
Enter password:
#新的密码
New password:
#确认密码
Confirm new password:
登录
PHP部分:
#获取rpm包
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#安装PHP
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache php72w-redis
#开启PHP
systemctl enable php-fpm --now
#查看版本
php -v
安装zabbix6.0.5
上传包
#解包
tar zxvf zabbix-6.0.5.tar.gz
#进入zabbix-6.0.5
cd zabbix-6.0.5/
#安装(容易报错,报错信息在下面)
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
#编译安装
make && make install
如果报一下错误
错误一:
解决方法
rpm -ivh /opt/mysql-community-devel-8.0.32-1.el7.x86_64.rpm
错误二:
或
解决方法:
#这个包在mysql-8.0的文件夹
rpm -ivh /opt/libevent-devel-2.0.21-4.el7.x86_64.rpm
yum -y install /opt/libevent-devel-2.0.21-4.el7.x86_64.rpm
yum install -y net-snmp-devel
编译完成后进入mysql
#进入数据库
mysql -uroot -pNihao123!
#创建zabbix库
create database zabbix character set utf8 collate utf8_bin;
#进入zabbix库
use zabbix
#导入zabbix数据(在zabbix安装包内)
source /root/zabbix-6.0.5/database/mysql/schema.sql;
source /root/zabbix-6.0.5/database/mysql/images.sql;
source /root/zabbix-6.0.5/database/mysql/data.sql;
#创建用户
create user zabbix@'192.168.100.%' identified by "Nihao123!";
#授权
grant all on zabbix.* to zabbix@'192.168.100.%' with grant option;
#刷新权限
flush privileges;
exit
#创建组
groupadd zabbix
#创建用户
useradd -r -g zabbix zabbix
#创建目录
mkdir /usr/local/zabbix/logs
#更改权限
chown zabbix:zabbix /usr/local/zabbix/ -R
zabbix-server
编辑zabbix-server的配置文件
vim /usr/local/zabbix/etc/zabbix_server.conf
#清除注释行和空行
:%g/^#/d
:%g/^$/d
#修改
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=192.168.100.5
DBName=zabbix
DBUser=zabbix
DBPassword=Nihao123!
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1,192.168.100.0/24
zabbix-agent
#编辑zabbix-agent配置文件
vim /usr/local/zabbix/etc/zabbix_agentd.conf
#清除注释行和空行
:%g/^#/d
:%g/^$/d
#修改
PidFile=/tmp/zabbix_agentd.pid
Server=192.168.100.5
Hostname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
启动查看
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd
netstat -utpln |grep 10051
netstat -utpln |grep 10050
编辑nginx配置文件
vim /etc/nginx/conf.d/default.conf
#修改第九行
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#在36行插入
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
#重启nginx
systemctl restart nginx
配置页面
#将zabbix页面移到nginx页面路径中
mv /root/zabbix-6.0.5/ui /usr/share/nginx/html/zabbix
#修改权限
chown -R nginx:nginx /usr/share/nginx/html/zabbix/
chown -R nginx:nginx /var/lib/php/session
编辑php文件
vi /etc/php.ini
#878行添加
date.timezone = Asia/Shanghai
#368行修改
max_execution_time = 300
#378行修改
max_input_time = 300
#656行修改
post_max_size = 32M
php配置完成后重启PHP
systemctl restart php-fpm
浏览器访问
看到有报错
安装后重启php,刷新
yum -y install php-bcmath
又报错
解决方法
#修改配置文件
vi /etc/my.cnf
#在mysqld中插入一行
[mysqld]
default-authentication-plugin=mysql_native_password
#重启mysqld
systemctl restart mysqld
#进入mysql
mysql -u root -pNihao123!
#进入mysql库
use mysql
#修改授权
ALTER USER 'zabbix'@'192.168.100.%' IDENTIFIED WITH mysql_native_password BY 'Nihao123!';
#刷新权限
flush privileges;
刷新页面
主机名称随便写
这个 报错点击下载配置文件,然后上传到/usr/share/nginx/html/zabbix/conf/
刷新页面
默认的账号密码
账号:Admin
密码:zabbix
有一个问题,就是在图形中有乱码
解决方法
在/usr/share/nginx/html/zabbix/assets/fonts/中,将原有的.ttf文件改名,再将自己准备的.ttf文件上传到此目录,并把名称改为原有.ttf的名称,这个.ttf文件我放到了mysql-8.0的文件夹里了
刷新一下页面就OK了
监控自己:
配置-》主机-》创建主机
如果mysql在监控时没有数据
#在MySQL数据库中创建监控账号并授权
CREATE USER 'zabbix'@'%'IDENTIFIED BY 'Nihao123!';
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zabbix'@'%';
flush privileges;
#创建目录
mkdir -p /var/lib/zabbix
#写入用户名和密码
vi /var/lib/zabbix/.my.cnf
[client]
user=zabbix
password=Nihao123!
socket=/var/lib/mysql/mysql.sock
[mysql]
user=zabbix
password=Nihao123!
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
user=zabbix
password=Nihao123!
socket=/var/lib/mysql/mysql.sock
#修改zabbix目录权限
chown zabbix:zabbix /var/lib/zabbix -R
cd /root/zabbix-6.0.5/conf/zabbix_agentd/
vim userparameter_mysql.conf
vi /usr/local/zabbix/etc/zabbix_agentd.conf
rm -rf /root/zabbix-6.0.5/conf/zabbix_agentd/userparameter_examples.conf
#重启zabbix_agent
killall -9 zabbix_agentd
/usr/local/zabbix/sbin/zabbix_agentd