安装配置nginx、php
#使用nginx官方源安装nginx
yum install nginx
#php安装
yum install epel-release
yum install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
yum install libxml2-devel sqlite-devel libcurl-devel libpng-devel libjpeg-turbo-devel libXpm-devel freetype-devel libicu-devel gcc-c++ libxslt-devel oniguruma-devel libsodium-devel openldap-devel net-snmp-devel libwebp-devel
yum --enablerepo=remi-php74 install php php-cli php-common php-devel php-embedded php-gd php-mbstring php-pdo php-xml php-fpm php-mysqlnd php-opcache php-mcrypt php-pecl-memcached php-pecl-mongodb php-pecl-redis php-bcmath php-intl php-xmlrpc php-pecl-zip php-soap php-snmp php-ldap
修改php-fpm用户
egrep "^(user|group)" /etc/php-fpm.d/www.conf
user = nginx
group = nginx
修改php.ini
vim /etc/php.ini
修改
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
nginx配置
vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html/zabbix;
try_files $uri $uri/ /index.php?query_string;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/share/nginx/html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
mysql服务器
注:mysql需要8.0
mysql服务器安装参考
https://blog.csdn.net/wuxingge/article/details/100774308
导入sql
ll zabbix-6.0.7/database/mysql/
总用量 34284
-rw-r--r-- 1 jenkins jenkins 32910804 7月 25 16:20 data.sql
-rw-r--r-- 1 jenkins jenkins 282 7月 25 16:06 double.sql
-rw-r--r-- 1 jenkins jenkins 1526 7月 25 16:20 history_pk_prepare.sql
-rw-r--r-- 1 jenkins jenkins 1978341 7月 18 15:31 images.sql
-rw-r--r-- 1 root root 16702 7月 30 22:17 Makefile
-rw-r--r-- 1 jenkins jenkins 508 7月 25 16:20 Makefile.am
-rw-r--r-- 1 jenkins jenkins 16352 7月 25 16:20 Makefile.in
-rw-r--r-- 1 jenkins jenkins 163854 7月 25 16:20 schema.sql
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix'@'%' identified by 'zabbix';
grant all privileges on zabbix.* to 'zabbix'@'%';
source schema.sql;
source images.sql;
source data.sql;
安装zabbix-server
安装mysql客户端
rpm -e mariadb-libs --nodeps
rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-devel-8.0.20-1.el7.x86_64.rpm --nodeps --force
安装zabbix-server
# 安装依赖:
yum install -y libssh2-devel unixODBC-devel ncurses-devel OpenIPMI-devel libevent-devel java-1.8.0-openjdk-devel openldap-devel gnutls-devel net-snmp-devel curl-devel
# 下载上传zabbix-6.0.0.tar.gz源码包并解压
tar xf zabbix-6.0.0.tar.gz
groupadd --system zabbix
useradd --system -g zabbix -d /app/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
./configure --prefix=/app/zabbix --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-jabber --with-ssh2 --with-zlib --with-libpcre --enable-java --with-ldap --with-gnutls
make
make install
cd zabbix-6.0.0
cp -r ui/* /usr/share/nginx/html/zabbix/
chmod 777 /usr/share/nginx/html/zabbix/conf
cd /app/zabbix
mkdir logs
chown -R zabbix:zabbix /app/zabbix
systemctl restart nginx.service
zabbix-server配置
egrep -v "#|^$" /app/zabbix/etc/zabbix_server.conf
LogFile=/app/zabbix/logs/zabbix_server.log
PidFile=/app/zabbix/logs/zabbix_server.pid
DBHost=192.168.41.70
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
zabbix-server启动文件
vim /etc/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/app/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/app/zabbix/sbin/zabbix_server
Type=forking
Restart=on-failure
PIDFile=/app/zabbix/logs/zabbix_server.pid
KillMode=control-group
ExecStart=/app/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
[Install]
WantedBy=multi-user.target
zabbix-agent
wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/7/x86_64/zabbix-agent2-6.0.7-1.el7.x86_64.rpm
yum localinstall zabbix-agent2-6.0.7-1.el7.x86_64.rpm
web访问
http://192.168.41.70/setup.php
zabbix6自带k8s监控模板
zabbix图形乱码问题
yum install wqy-microhei-fonts
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/nginx/html/zabbix/assets/fonts/DejaVuSans.ttf