본문 바로가기

리눅스

[draft] 우분투에서 Zabbix 7 LTS를 설치하고 설정하는 방법

728x90

우분투에서 Zabbix 7.0 LTS를 설치하고 설정하는 방법

1. 시스템 업데이트 및 필요한 패키지 설치

sudo apt update
sudo apt install -y curl gnupg2 ca-certificates lsb-release
sudo apt install -y ubuntu-keyring apt-transport-https

2. NGINX 설치

더보기

---

curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install -y nginx
$ nginx -v
nginx version: nginx/1.26.2
sudo systemctl --now enable nginx
sudo systemctl restart nginx
sudo systemctl status nginx

---

3. PHP(PHP-FPM) 설치

더보기

---

sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt install -y php8.3 php8.3-cli php8.3-fpm php8.3-common \
    php8.3-mysql php8.3-gd php8.3-xml php8.3-bcmath php8.3-mbstring php8.3-ldap php8.3-opcache
$ php -v
PHP 8.3.13 (cli) (built: Oct 30 2024 11:27:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.13, Copyright (c), by Zend Technologies
sudo systemctl --now enable php8.3-fpm
sudo systemctl restart php8.3-fpm
sudo systemctl status php8.3-fpm

---

4. MySQL 설치

더보기

---

wget https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.33-1_all.deb
sudo apt update
sudo apt install -y mysql-server
$ mysql --version
mysql  Ver 8.4.3 for Linux on x86_64 (MySQL Community Server - GPL)
sudo systemctl --now enable mysql
sudo systemctl restart mysql
sudo systemctl status mysql

---

5. Zabbix 저장소 추가 및 설치

Zabbix 저장소를 추가하고 패키지를 설치합니다.

wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_latest+ubuntu22.04_all.deb
sudo apt update
sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
$ zabbix_server -V
zabbix_server (Zabbix) 7.0.5
Revision 9406e67a5ff 21 October 2024, compilation time: Oct 21 2024 12:46:31

Copyright (C) 2024 Zabbix SIA
License AGPLv3: GNU Affero General Public License version 3 <https://www.gnu.org/licenses/>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 3.0.2 15 Mar 2022
Running with OpenSSL 3.0.2 15 Mar 2022

6. MySQL 설정

Zabbix 데이터베이스와 사용자 계정을 생성하고 권한을 부여

mysql -uroot -p
CREATE DATABASE zabbixdb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
FLUSH PRIVILEGES;
quit;

Zabbix 데이터베이스 초기화

  • Zabbix 데이터베이스에 테이블을 생성합니다.
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbixdb

데이터베이스 스키마를 가져온 후 log_bin_trust_function_creators 옵션을 비활성화

mysql -uroot -p
SET GLOBAL log_bin_trust_function_creators = 0;
quit;
728x90

7. Zabbix 서버 설정 파일  편집

데이터베이스 정보를 입력합니다.

sudo vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbixdb
DBUser=zabbix
DBPassword=password

8. NGINX 설정

nginx.conf 설정 파일 편집

sudo vim /etc/nginx/nginx.conf
더보기

---

cat /etc/nginx/nginx.conf
user  www-data www-data;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

---

user  www-data www-data;

zabbix.conf 설정 파일 편집

sudo vim /etc/nginx/conf.d/zabbix.conf
더보기

---

server {
#        listen          8080;
#        server_name     example.com;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale) {
                deny            all;
                return          404;
        }

        location /vendor {
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_pass    unix:/var/run/php/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}

---

server {
        listen          80;
        server_name     zbx.sangchul.kr;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale) {
                deny            all;
                return          404;
        }

        location /vendor {
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_pass    unix:/var/run/php/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}

9. PHP(PHP-FPM) 설정

php-fpm 로그 디렉토리 생성

sudo mkdir -p /var/log/php-fpm

php-fpm.conf 설정 파일 편집

sudo vim /etc/php/8.3/fpm/php-fpm.conf
[global]
pid = /run/php/php8.3-fpm.pid
error_log = /var/log/php-fpm/php8.3-fpm.log
include = /etc/php/8.3/fpm/pool.d/*.conf

zabbix-php-fpm.conf 설정 파일 편집

sudo vim /etc/php/8.3/fpm/pool.d/zabbix-php-fpm.conf
더보기

---

cat /etc/php/8.3/fpm/pool.d/zabbix-php-fpm.conf
[zabbix]
user = www-data
group = www-data

listen = /var/run/php/zabbix.sock
listen.owner = www-data
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/sessions/

php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000

---

[zabbix]
user = www-data
group = www-data

listen = /var/run/php/zabbix.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

ping.path = /ping
pm.status_path = /status

request_terminate_timeout = 30
request_slowlog_timeout = 10
slowlog = /var/log/php-fpm/$pool-slow.log

access.log = /var/log/php-fpm/$pool-access.log
access.format = "[%t] %m %{REQUEST_SCHEME}e://%{HTTP_HOST}e%{REQUEST_URI}e %f pid:%p TIME:%ds MEM:%{mega}Mmb CPU:%C%% status:%s {%{REMOTE_ADDR}e|%{HTTP_USER_AGENT}e}"

php_admin_value[error_log] = /var/log/php-fpm/$pool-error.log
php_admin_flag[log_errors] = on

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/sessions/

php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000

NGINX, PHP(PHP-FPM) 설정 파일 문법 검사

nginx -t
php-fpm8.3 -t
sudo systemctl restart nginx php8.3-fpm

Zabbix 서버를 시작하고 부팅 시 자동으로 시작되도록 설정

sudo systemctl enable zabbix-server zabbix-agent
sudo systemctl restart zabbix-server zabbix-agent

10. 웹 설치 마법사

웹 브라우저에서 Zabbix 웹 설치 마법사를 완료합니다.

http://your_domain_or_IP

Zabbix_Server

한국어 로케일 설치(선택 사항)

현재 로케일 확인

locale -a
C
C.utf8
en_US.utf8
POSIX

(또는)

locale | egrep 'LANG|LC_CTYPE|LC_MESSAGES'
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"

한국어 로케일 생성

sudo locale-gen ko_KR.UTF-8
Generating locales (this might take a while)...
  ko_KR.UTF-8... done
Generation complete.

로케일 설정 적용

sudo update-locale

설정된 로케일 확인

locale -a | egrep 'ko_KR'
ko_KR.utf8

웹 서버 및 PHP-FPM 재시작

sudo systemctl restart nginx php8.3-fpm

11. Zabbix 웹 인터페이스 접속

http://your_domain_or_IP

관리자 페이지의 기본 로그인 정보

  • Username: Admin
  • Password: zabbix

Zabbix_Server
Zabbix_Server
Zabbix_Server

 

Zabbix 7.0 LTS가 성공적으로 설치되어 사용 가능합니다.

 

참고URL

- Zabbix Documentation : requirements

- MySQL Community Downloads : MySQL 8.3(mysql-apt-config_0.8.33-1_all.deb)

- Zabbix Download : Zabbix 7.0(zabbix-release_latest+ubuntu22.04_all.deb)

 

728x90