LoginSignup
4
4

More than 5 years have passed since last update.

CentOS 7、PHP 7.2 の環境に Zabbix 3.4 をインストールする

Last updated at Posted at 2018-02-20

まっさらな CentOS 7 に Zabbix をインストールする手順です。

Zabbix 公式手順でそのままインストールすると PHP 5.4 がインストールされてしまうので、PHP 7.2 のインストールを加えています。

構成

  • Zabbix 3.4
  • Apache 2.4
  • PHP 7.2
  • MariaDB 5.5

SELinux、ファイアウォールは無効化してあり、VPS のネットワーク設定で通信の制御を行っている前提です。

通信に必要なポートは下記の通り。

  • 22 -> SSH
  • 80 -> http
  • 443 -> https
  • 10051 -> Zabbix Agent からの通信を受け入れる

手順

SSH でログイン後、root ユーザーに切り替えて作業を行なう。

リポジトリの登録

remi リポジトリは PHP 7.2 をインストールするために、zabbix リポジトリは Zabbix 3.4 をインストールするために登録します。

sudo su
yum -y install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum update

パッケージのインストール

パッケージのインストールを行ないます。

PHP 7.2 をインストールするために remi-php72 を有効化しています。

yum --enablerepo=remi,remi-php72 install \
zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent \
mariadb mariadb-server

MariaDB を起動

MariaDB を起動し、マシンが起動するとともに MariaDB も起動するよう登録します。

systemctl start mariadb
systemctl enable mariadb

データベースの初期設定

MariaDB にログインし、Zabbix 用のデータベースを作成します。

mysql -u root -p

password となったいるところは適宜別のものに書き換えます。

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
quit;

データベースの作成後、SQL コンソールから出て、Zabbix のスクリプトを MariaDB に流し込みます。

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

Zabbix の設定ファイルを編集

zabbix_server.conf を編集します。

vi /etc/zabbix/zabbix_server.conf

先ほど作成したデータベース名、ユーザー名、パスワードを設定ファイルに書き込みます。

zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password

ウェブサーバーの設定

Zabbix をインストールするとウェブサーバーとともに設定ファイルも同時にインストールされます。

ただし、PHP のバージョンや地域に関する記述を編集する必要があります。

vi /etc/httpd/conf.d/zabbix.conf
zabbix.conf
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
-   <IfModule mod_php5.c>
+   <IfModule mod_php7.c>
        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 always_populate_raw_post_data -1
-       # php_value date.timezone Europe/Riga
+       php_value date.timezone Asia/Tokyo
    </IfModule>
</Directory>

サービスの起動

Zabbix Server、Zabbix agent、ウェブサーバーを起動し、自動起動に登録します。

systemctl start zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4