建议不要在centos上安装,如果你在CentOS7.9版本上编译,可能会因为默认libevent和net-snmp版本过低导致编译失败,升级libevent到2.1.2版本,net-snmp到net-snmp-5.9.3版本后才可编译安装成功。
本次采用Debian 12安装,mysql+php+nginx
操作系统镜像下载地址:https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso
数据库采用mysql,需要8.0.30以后版本,不能是8.04
wget https://dev.mysql.com/get/mysql-apt-config_0.8.30-1_all.deb apt update apt install ./mysql-apt-config_0.8.30-1_all.deb
注:MySQL最新版源可在 MySQL :: Download MySQL APT Repository 下载。
安装源时,依次选择:
MySQL Server & Cluster (Currently selected: mysql-8.4-lts)
mysql-8.0
ok
然后开始安装并启动:
sudo apt update apt install mysql-server 弹出设置栏时,手动设置root密码 systemctl start mysql systemctl enable mysql
#进入数据库
mysql -uroot -pQWERasdf1234
创建存储数据的库,并支持中文(库名:zabbix)
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
#授权连接数据库的用户,并设置密码(用户名:zabbix)
mysql> create user zabbix@localhost identified by '123456';
#数据库授权等
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
apt update && apt install -y nginx lsb-release ca-certificates curl curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' apt install -y php8.2 php8.2-cli php8.2-common php8.2-dev php8.2-gd php8.2-mbstring php8.2-pdo php8.2-xml php8.2-fpm php8.2-mysql php8.2-opcache php8.2-ldap php8.2-bcmath
将server_name改为本机地址 # vim /etc/nginx/conf.d/zabbix.conf server { listen 80; server_name 192.168.150.133; root /usr/share/nginx/html; location / { index index.php index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } #修改 php 配置 #vim /etc/php/8.2/fpm/pool.d/www.conf +274 pm.status_listen = 0.0.0.0:9001 # vim /etc/php/8.2/cli/php.ini max_execution_time = 300 max_input_time = 600 post_max_size = 80M date.timezone = Asia/Shanghai # vim /etc/php/8.2/fpm/php.ini max_execution_time = 300 max_input_time = 600 post_max_size = 80M date.timezone = Asia/Shanghai #创建测试文件,启动服务 # vim /usr/share/nginx/html/index.php # systemctl start nginx php8.2-fpm # systemctl enable nginx php8.2-fpm
#下载zabbix7.0源码包 cd / && mkdir /data && cd /data #检查缺不缺少ldconfig和start-stop-daemon ls /sbin/ldconfig && ls /usr/sbin/start-stop-daemon #编辑变量 vim ~/.bashrc #文件末尾加上 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" #保存退出后设置环境变量 source ~/.bashrc wget https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb dpkg -i zabbix-release_7.0-1+debian12_all.deb apt update apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent #导入zabbix初始数据 # zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p123456 -Dzabbix #修改配置文件指定数据库: vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 #启动zabbix_server服务 systemctl start zabbix-server zabbix-agent nginx php8.2-fpm systemctl enable zabbix-server zabbix-agent nginx php8.2-fpm
#删除测试文件 rm -rf /usr/share/nginx/html/* #把zabbix前端代码移到/usr/share/nginx/html/ cd /usr/share/zabbix && mv * /usr/share/nginx/html/ #修改前端代码所属组所属主 chown -R www-data /usr/share/nginx/html/ #重启nginx systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm
zabbix server服务名:zabbix-server 端口:10051
zabbix agent服务名:zabbix-agent端口:10050
zabbix server主配置文件:/etc/zabbix/zabbix_server.conf
zabbix agent主配置文件:/etc/zabbix/zabbix_agentd.conf
zabbix企业微信报警脚本路径:/usr/lib/zabbix/alertscripts
zabbix自定义监控项路径:/etc/zabbix/zabbix_agentd.d
日志文件路径:/var/log/zabbix/
默认账户名Admin/zabbix,登录