# Installation

##### Tutorials

- RHEL7/8: [https://www.zabbix.com/documentation/current/manual/installation/install\_from\_packages/rhel\_centos](https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/rhel_centos)
- [How To Install Zabbix Server 5.0 on CentOS 7](https://computingforgeeks.com/how-to-install-zabbix-server-on-centos-7/)

##### Platform to install

<table border="1" id="bkmrk-zabbix-version-5.0-l" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 50%;">Zabbix Version</td><td style="width: 50%;">5.0 LTS</td></tr><tr><td style="width: 50%;">OS Distribution</td><td style="width: 50%;">CENTOS</td></tr><tr><td style="width: 50%;">OS Version</td><td style="width: 50%;">7</td></tr><tr><td style="width: 50%;">Database</td><td style="width: 50%;">MySQL</td></tr><tr><td style="width: 50%;">Web Server</td><td style="width: 50%;">Apache</td></tr></tbody></table>

##### Prerequisites

php 7.2

> Zabbix frontend requires PHP version **7.2 or newer** starting with Zabbix 5.0. Note that RHEL/CentOS 7 only provide PHP 5.4. So don't install the php for pre-installed version on system.

##### Step 1: Install and Configure Apache httpd server

```
yum install httpd
systemctl start httpd
systemctl enable httpd
```

##### Step 2: Install MariaDB Database server

Remove MariaDB 5.x

```
systemctl stop mariadb
yum remove mariadb mariadb-server mariadb-libs
```

<span data-position="5776" data-size="26">Add new MariaDB repository</span>  
[<span data-position="5803" data-size="116">https://downloads.mariadb.org/mariadb/repositories/#mirror=mephi&amp;distro=CentOS&amp;distro\_release=centos7-amd64--centos7</span>](https://downloads.mariadb.org/mariadb/repositories/#mirror=mephi&distro=CentOS&distro_release=centos7-amd64--centos7)

```
vi /etc/yum.repos.d/mariadb.repo
```

```
# MariaDB 10.5 CentOS repository list - created 2020-08-17 13:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
```

Install MariaDB

```
yum clean all
yum install MariaDB-server MariaDB-client
```

Config MariaDB

```
vi /etc/my.cnf.d/server.cnf
```

```
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
```

新增目錄

```
mkdir /var/log/mariadb
chown mysql.mysql /var/log/mariadb
```

Start MariaDB

```
systemctl start mariadb
systemctl enable mariadb
```

Initial DB Configuration and set password for root

```
mysql_secure_installation
```

##### Step 3: Install and configure Zabbix server

a. Install Zabbix repository

```
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
```

b. Install Zabbix server and agent

```
# yum install zabbix-server-mysql zabbix-agent zabbix-get
```

c. Install Zabbix frontend  
Enable Red Hat Software Collections

```
# yum install centos-release-scl
```

Install Zabbix frontend packages.

<p class="callout info">This step will install the php 7.2 packages required for Zabbix.</p>

```
# yum-config-manager --enable zabbix-frontend
# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
```

> 如果沒有安裝 yum-config-manager，可以改用以下指令安裝：
> 
> `yum --enablerepo=zabbix-frontend`

<div id="bkmrk-d.-create-initial-da"><div>d. Create initial database</div><div>Run the following on your database host.</div></div>```
# mysql -uroot -p <<MYSQL_EOF
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'thisispassword';
grant all privileges on zabbix.* to zabbix@localhost;
MYSQL_EOF
```

<div id="bkmrk-on-zabbix-server-hos">On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.</div>```
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
```

<div id="bkmrk-e.-configure-the-dat">e. Configure the database for Zabbix server</div><div id="bkmrk-edit-file-%2Fetc%2Fzabbi">Edit file `/etc/zabbix/zabbix_server.conf`</div>```
DBName=zabbix
DBUser=zabbix
DBPassword=password
```

<div id="bkmrk-f.-configure-php-for">f. Configure PHP for Zabbix frontend</div><div id="bkmrk-edit-file-%2Fetc%2Fopt%2Fr">Edit file `/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf`, uncomment and set the right timezone for you.</div>```
php_value[date.timezone] = Asia/Taipei
```

<div id="bkmrk-g.-start-zabbix-serv">g. Start Zabbix server and agent processes</div><div id="bkmrk-start-zabbix-server-">Start Zabbix server and agent processes and make it start at system boot.</div>```
# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
```

<div id="bkmrk-h.-configure-zabbix-">h. Configure Zabbix frontend</div><div id="bkmrk-connect-to-your-newl">Connect to your newly installed Zabbix frontend: `http://server_ip_or_name/zabbix`</div><div id="bkmrk-">[![zabbix-install-home.png](http://www.osslab.tw:8880/uploads/images/gallery/2020-08/scaled-1680-/zabbix-install-home.png)](http://www.osslab.tw:8880/uploads/images/gallery/2020-08/zabbix-install-home.png)</div>##### Optional: Other Zabbix components Installation

<div id="bkmrk-zabbix-proxy">Zabbix-Proxy</div>```
yum install zabbix-proxy-mysql
```

<div id="bkmrk-java-gateway">Java Gateway</div>```
yum install zabbix-java-gateway
```

<div id="bkmrk--0"></div>