zabbix部署
nginx源
[root@iZn4a6s5fi2h7kyz8vqiagZ fonts]# nginx -v
nginx version: nginx/1.26.1
[root@iZn4a6s5fi2h7kyz8vqiagZ fonts]# cat /etc/yum.repos.d/Nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@iZn4a6s5fi2h7kyz8vqiagZ fonts]#
mariadb源
[root@iZn4a6s5fi2h7kyz8vqiagZ fonts]# cat /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.11 RedHatEnterpriseLinux repository list - created 2025-06-04 05:42 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.11/rhel/$releasever/$basearch
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.11/rhel/$releasever/$basearch
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
[root@iZn4a6s5fi2h7kyz8vqiagZ fonts]#
php-remi源
https://www.kdocs.cn/l/cefBh5PbIT86
部署nginx+php环境
安装php依赖
yum install php72-php-cli php72-php-fpm php72-php-gd php72-php-mbstring php72-php-bcmath php72-php-xml php72-php-ldap php72-php-mysqlnd -y
nginx配置文件
conf.d/zbx.oldboylinux.cn.conf
server {
listen 80;
server_name zbx.oldboylinux.cn;
root /app/code/zbx;
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;
}
}
php默认配置更改
// 用户名
1. 进行替换
sed -ri '/^(user|group)/s#apache#nginx#g' /etc/phpfpm.d/www.conf
2. 进行检查
egrep '^(user|group)' /etc/php-fpm.d/www.conf
user = nginx
group = nginx
// 服务启动
systemctl enable nginx php-fpm
systemctl start nginx php-fpm
// 测试phpinfo
cat /app/code/zbx/info.php
<?php
phpinfo();
?>
mariadb数据库配置
#1. 创建数据库要指定字符集
create database zabbix charset utf8 collate
utf8_bin;
#2. 创建zabbix用户
grant all on zabbix.* to 'zabbix'@'localhost'
identified by 'zabbix' ;
#如果数据库与zbx,php不在一起
#grant all on zabbix.* to 'zabbix'@'172.16.1.%'
identified by 'zabbix' ;
// 源码导入
sql文件在源代码中.
tar xf zabbix-6.0.14.tar.gz
cd zabbix-6.0.14/database/mysql/
mysql zabbix <schema.sql
mysql zabbix <images.sql
mysql zabbix <data.sql
mysql zabbix <double.sql
mysql zabbix <history_pk_prepare.sql
// 检查
178 rows in set (0.001 sec)
mysql -e 'show tables from zabbix;' |wc -l
179
zabbix-server编译
// 1. 安装依赖(软件包中已经包含)
yum install -y mysql-devel pcre-devel openssl-devel
zlib-devel libxml2-devel net-snmp-devel net-snmp
libssh2-devel OpenIPMI-devel libevent-devel
openldap-devel libcurl-devel
// 安装及验证
./configure sysconfdir=/etc/zabbix/ --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre
make install
echo $?
zabbix-server服务端配置文件
[root@m03-zabbix-server-lidao996 ~]# grep -n '^[aZ]' /etc/zabbix/zabbix_server.conf
12:ListenPort=10051
38:LogFile=/tmp/zabbix_server.log
87:DBHost=localhost
99:DBName=zabbix
115:DBUser=zabbix
123:DBPassword=zabbix
507:Timeout=4
593:LogSlowQueries=3000
708:StatsAllowedIP=127.0.0.1
zabbix-server启动
添加个虚拟用户
useradd -s /sbin/nologin -M zabbix
zabbix_server 启动zbx服务端
检查端口
ss -lntup|grep 10051
检查进程
ps -ef |grep zabbix
// 1. 书写systemctl配置文件
cat /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server with MySQL DB
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/local/sbin/zabbix_server -f
User=zabbix
[Install]
WantedBy=multi-user.target
// 2. 加载配置文件
systemctl daemon-reload
// 3. 关闭手动启动的zbx server
pkill zabbix_server
// 4. 检查是否关闭成功
ps -ef |grep zabbix
// 5. 启动与检查
systemctl enable zabbix-server
systemctl start zabbix-server
systemctl status zabbix-server
页面前端代码部署:
cp -r zabbix-6.0.5/ui /app/code/zbx/
chown -R nginx.nginx /app/code/zbx/
页面显示php需修改:
egrep -n '^(max_.*_time|post_max)' /etc/php.ini
368:max_execution_time = 300
378:max_input_time = 600
656:post_max_size = 80M
重启php
// 默认账号密码
Admin
zabbix
// 前端配置文件
egrep 'DB|ZBX_SERVER_NAME' zabbix.conf.php
zabbix-agent2安装:
// 1. 配置zbx源
[root@iZn4a6s5fi2h7kyz8vqiagZ ~]# cat !$/zabbix-agent.repo
cat /etc/yum.repos.d//zabbix-agent.repo
[zabbix]
name=Zabbix Official Repository (Aliyun Mirror) - $releasever - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/6.0/rhel/$releasever/$basearch/
enabled=1
gpgcheck=0
[root@iZn4a6s5fi2h7kyz8vqiagZ ~]#
// 2. 安装客户端
yum install -y zabbix-agent2
// 3. 配置客户端
[root@m03-zabbix-server-lidao996 ~]# grep '^[a-Z]'
/etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
// 4. 启动
systemctl enable zabbix-agent2.service
systemctl start zabbix-agent2.service
[root@m03-zabbix-server-lidao996 ~]# ps -ef |grep
agent2
zabbix 35508 1 0 16:17 ? 00:00:00
/usr/sbin/zabbix_agent2 -c
/etc/zabbix/zabbix_agent2.conf
root 35580 21162 0 16:17 pts/0 00:00:00
grep color=auto agent2
[root@m03-zabbix-server-lidao996 ~]# ss -lntup |grep
agent2
tcp LISTEN 0 128 []:10050
[]:* users:
(("zabbix_agent2",pid=35508,fd=8))
[root@m03-zabbix-server-lidao996 ~]#
乱码问题:
cd /app/code/zbx/assets/fonts/
上传一个中文的ttf字体替换zabbix自用的字体即可.
cp /code/zabbix/assets/fonts/DejaVuSans.ttf{,.bak}
cp msyh.ttc
/code/zabbix/assets/fonts/DejaVuSans.ttf
// windows字体目录地址:
C:\Windows\Fonts

浙公网安备 33010602011771号