CentOS 8 安裝 Zabbix server 4.4 與LEMP環境

LEMP環境建置部分

安裝nginx

yum -y install nginx

安裝php

yum -y install php php-fpm php-mysqlnd php-opcache php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

安裝MariaDB(MySQL)

yum -y install mariadb-server mariadb

記得用mysql_secure_installation更改root密碼

開通防火牆

firewall-cmd –permanent –add-service=http
firewall-cmd –permanent –add-service=https
firewall-cmd –permanent –add-port=3306/tcp
firewall-cmd –reload

開機自動啟動

systemctl enable mariadb
systemctl enable php-fpm
systemctl enable nginx

啟動

systemctl start php-fpm
systemctl start nginx
systemctl start mariadb

Zabbix 4.4部分

安裝repo

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
dnf clean all

安裝相關套件

yum -y install zabbix-server-mysql zabbix-agent zabbix-nginx-conf zabbix-web-mysql

登入mysql建立資料庫

mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘DB的密碼’;
mysql> quit;

匯入DB資料

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

修改 /etc/zabbix/zabbix_server.conf
vi /etc/zabbix/zabbix_server.conf

更改

#DBPassword=

DBPassword=DB的密碼

修改/etc/nginx/conf.d/zabbix.conf

vi /etc/nginx/conf.d/zabbix.conf

#listen 80;
#server_name example.con;

改為
listen 80 default_server;
listen [::]:80 default_server;
server_name _;

修改/etc/nginx/nginx.conf

vi /etc/nginx/nginx.conf

server {   listen       80 default_server;   listen       [::]:80 default_server;  server_name  _;  root         /usr/share/nginx/html;  # Load configuration files for the default server block.   include /etc/nginx/default.d/*.conf;   location / {   }   error_page 404 /404.html;       location = /40x.html {   }   error_page 500 502 503 504 /50x.html;       location = /50x.html {   }}

註解掉

修改/etc/php-fpm.d/zabbix.conf

vi  /etc/php-fpm.d/zabbix.conf

; php_value[date.timezone] = Europe/Riga

改為

php_value[date.timezone] = Asia/Taipei

設定SELinux

setenforce 0
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

啟動並開機執行

systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent

留言

這個網誌中的熱門文章

OpenVPN Server build on Debian 11

OpenWRT dumb AP with WPA3-SAE + 802.11r