How to Install Zabbix 4 on Ubuntu Linux

This tutorial will show you all the steps required to install Zabbix 4 on Ubuntu Linux.

This tutorial was tested on Ubuntu 18.04.

1. Configure Date and Time using NTP

It is very important to keep your system with the correct date and time.

Set the correct timezone.

# dpkg-reconfigure tzdata

Install the Ntpdate package and set the correct date and time.

# apt-get update
# apt-get install ntpdate
# ntpdate pool.ntp.br

Disable the Ubuntu default NTP client.

Install the NTP service to keep the computer date and time updated after a reboot.

# timedatectl set-ntp 0
# apt-get install ntp

Make sure the correct date and time have been set on your computer.

# date

2. Install MySQL on Ubuntu Linux

Zabbix requires a database system to store all its configuration.

Use the Ubuntu APT command to install the MySQL server.

# apt-get update
# apt-get install mysql-server mysql-client

Use the following command to access the MySQL service console.

# mysql -u root -p

On the MySQL console, you need to perform the following tasks:

• Create a database named zabbix.
• Create a MySQL user account named zabbix.
• Give full control over the zabbix database to the zabbix user.

CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;
CREATE USER 'zabbix'@'%' IDENTIFIED BY 'kamisama123';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%';
quit;

Download the Zabbix installation package to get the database templates.

# mkdir /downloads
# cd /downloads
# wget https://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz

Extract the Zabbix installation package.

Import the Zabbix database templates inside the MySQL database.

When asked, you need to enter the MySQL password for the Zabbix user.

# tar -zxvf zabbix-4.0.3.tar.gz
# cd zabbix-4.0.3/database/mysql/
# mysql -u zabbix -p zabbix < schema.sql
# mysql -u zabbix -p zabbix < images.sql
# mysql -u zabbix -p zabbix < data.sql

The Zabbix database installation was completed.

3. Install Apache on Ubuntu Linux

Use the Ubuntu APT command to install the Apache server and the required PHP modules.

# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# apt-get install php7.2-mbstring php7.2-xml php7.2-gd
# apt-get install php7.2-curl php7.2-bcmath php7.2-ldap

Find the location of the PHP configuration file on your system.

Edit the php.ini configuration file.

# updatedb
# locate php.ini
# vi /etc/php/7.2/apache2/php.ini

Your PHP version may not be the same as ours.

Your PHP configuration file location may not be the same as ours.

Modify the following items in the php.ini configuration file.

max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
max_input_time = 300
date.timezone = America/Sao_Paulo

Your timezone may not be the same as ours.

Restart the Apache web server manually.

# service apache2 restart
# service apache2 status

Verify the Apache service status.

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Mon 2018-12-03 03:41:12 -02; 2 days ago

The Apache server installation was completed.

4. Install Zabbix 4 on Ubuntu Linux

After finishing the MySQL and the Apache configuration, we can start the Zabbix installation.

Create the required a user account to the Zabbix service.

# groupadd zabbix
# useradd -g zabbix -s /bin/bash zabbix

Use the Ubuntu APT command to install the required packages.

# apt-get install build-essential libmysqlclient-dev libssl-dev libsnmp-dev libevent-dev
# apt-get install libopenipmi-dev libcurl4-openssl-dev libxml2-dev libssh2-1-dev libpcre3-dev
# apt-get install libldap2-dev libiksemel-dev libcurl4-openssl-dev libgnutls28-dev

Access the directory where the Zabbix installation package was downloaded.

Compile and install the Zabbix server application.

# cd /downloads/zabbix-4.0.3/
# ./configure --enable-server --enable-agent --with-mysql --with-openssl --with-net-snmp --with-openipmi --with-libcurl --with-libxml2 --with-ssh2 --with-ldap
# make
# make install

Find the location of the Zabbix server configuration file on your system.

Edit the zabbix_server.conf configuration file.

# updatedb
# locate zabbix_server.conf
# vi /usr/local/etc/zabbix_server.conf

Here is the original file, before our configuration.

LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
Timeout=4
LogSlowQueries=3000

Here is the new file with our configuration.

LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=kamisama123
Timeout=4
LogSlowQueries=3000

Start the Zabbix server using the following command.

# /usr/local/sbin/zabbix_server

Start the Zabbix agent application using the following command.

# /usr/local/sbin/zabbix_agentd

Optional! The Zabbix installation package offers service startup scripts.

Copy the Zabbix startup script.

# cd /downloads/zabbix-4.0.3/
# cp misc/init.d/debian/* /etc/init.d/

You can now use the following commands to start the Zabbix server service.

# /etc/init.d/zabbix-server start

You can now use the following commands to stop the Zabbix server service.

# /etc/init.d/zabbix-server stop

Move the Zabbix frontend files inside your Apache root drive directory.

Give the www-data user full control over the Zabbix directory and its files.

# cd /downloads/zabbix-4.0.3/frontends
# mv php /var/www/html/zabbix
# chown www-data.www-data /var/www/html/zabbix/* -R

Restart the Apache service.

# service apache2 stop
# service apache2 start

5. Configure Zabbix on Ubuntu Linux

Open your browser and enter the IP address your web server plus /zabbix.

In our example, the following URL was entered in the Browser:

• http://200.200.200.200/zabbix

The Zabbix installation wizard will be presented.

Zabbix Installation

Verify if all Zabbix requirements were met successfully.

Zabbix Requirements

Enter the MySQL login information required to connect to the Zabbix database

Zabbix database connetion

Click on the Next button.

Zabbix Agent Connection

Verify the Zabbix installation summary.

Zabbis Installation Summary

Click on the Finish button to access the Zabbix Login screen.

Zabbix installation finished

On the Zabbix logins screen, enter the following information.

• Zabbix default username: Admin
• Zabbix default Password: zabbix

Zabbix Login

After a successful login, The Zabbix dashboard will be displayed.

Zabbix Dashboard

Congratulations, Zabbix is installed on your system.

6. Monitor the Zabbix Server

The Zabbix server must be able to monitor itself.

On the Zabbix dashboard, access the Configuration menu and select the Host option.

Zabbix menu

On the top right of the screen, select the option named: Zabbix servers

Zabbix Server Group

Locate the host named Zabbix server and click on the word DISABLED.

This will enable the Zabbix server to monitor itself.

Zabbix server agent disabled

The Zabbix server status will turn from DISABLED to ENABLED.

The Zabbix server is now monitoring itself.