How to install and configure Zabbix on Ubuntu 18.04

s2 0

Zabbix is ​​one of the most popular open source monitoring software tools. Zabbix collects metrics from your network devices, systems, and applications and makes sure they are up and running. In the event of problems, Zabbix sends notifications using various methods.

Zabbix can be deployed for agent-based and agentless monitoring. The Zabbix agent has a small footprint and can run on a variety of platforms including Linux, UNIX, macOS, and Windows.

This tutorial describes how to install and configure the latest version of Zabbix 4.0 on an Ubuntu 18.04 server with MySQL as the database back end. We will also show you how to install the Zabbix agent on a remote host and add the host to the Zabbix server.


Before proceeding with this tutorial, make sure that you are logged in as a user with sudo permissions.

Create MySQL database

Zabbix supports both MySQL / MariaDB and PostgreSQL. In this tutorial we will use MySQL as the database back end.

If you haven’t already installed MySQL on your Ubuntu server, here’s how to install it.

Log into the MySQL shell by entering the following command:

sudo mysql

In the MySQL shell, execute the following SQL statement to create a new database:

CREATE DATABASE zabbix CHARACTER SET utf8 collate utf8_bin;

Next, create a MySQL user account and grant access to the database:

GRANT ALL ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'change-with-strong-password';
Make sure you change yourself change-with-strong-password with a strong password.

When you’re done, exit the MySQL console by typing:


Install Zabbix on Ubuntu

At the time of this writing, the latest stable release of Zabbix is ​​version 4.0. The Zabbix packages available in Ubuntu repositories are often out of date, so we use the official ones Zabbix repository

1. Install Zabbix

Download the latest Zabbix repository .deb Package with the following wget command:


Once the file is downloaded, add the Zabbix repository to your Ubuntu 18.04 system by typing:

sudo apt install ./zabbix-release_4.0-2+bionic_all.deb

Update the package index and install the Zabbix server, the web front end with MySQL database support and the Zabbix agent:

sudo apt updatesudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

The above command will also install Apache, PHP, and any required PHP modules.

2. Configure PHP for the Zabbix frontend

During the installation, an Apache configuration file is created that contains all of the required Apache and PHP settings. All you need to do is make a small change and set the appropriate time zone.

Open the configuration file, uncomment the time zone line, and change it to your time zone. Here is the full list of time zones supported by PHP here

    <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 max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone America/Denver

Then save the configuration file and restart the Apache service for the changes to take effect:

sudo systemctl restart apache2

3. Configuration of the MySQL database for Zabbix server

The Zabbix installation package contains a dump file that contains an initial schema and data for the Zabbix server with MySQL.

Import the MySQL dump file by running:

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

When prompted, enter the user password you created earlier. If successful, there is no output.

Next we need to edit the Zabbix configuration and set the database password.

Open the configuration file in your editor:

sudo nano /etc/zabbix/zabbix_server.conf

Look for the following section, uncomment the DBPassword Statement and add the database password.

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
# Mandatory: no
# Default:

Save and close the file.

Restart the Zabbix server and agent services and let them start at system startup:

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

To check if the Zabbix server is running, enter:

sudo systemctl status zabbix-server
● zabbix-server.service - Zabbix Server
   Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-11-29 03:30:44 PST; 43s ago
 Main PID: 14293 (zabbix_server)
    Tasks: 34 (limit: 2319)
   CGroup: /system.slice/zabbix-server.service

Install and configure Zabbix Frontend

The Zabbix web interface is written in PHP and allows us to configure the server, view collected data and add hosts that we want to monitor.

Before we can use the web interface, we need to install it.

Open your preferred browser and enter your server’s domain name or public IP address followed by /zabbix:


You will see a welcome message on the first screen. click Next step keep going.

Next, you’ll see the information page below, which lists all of the PHP prerequisites required to run the Zabbix front end. All values ​​in this table should OK, scroll down to check that everything is set up correctly. After confirming, click Next step Continue.

On the next screen, the setup wizard will prompt you for your database connection details. Enter the MySQL user and database details you created earlier.

Entering a name for the server is optional. Enter it if you have more than one Zabbix monitoring server. If available, it will be displayed in the menu bar and in the page titles.

click Next step keep going.

On the next screen you will see the summary before the installation.

click Next step and once the installation is complete, you will be redirected to a page informing you that the Zabbix web interface has been installed. To access your Zabbix login page, click the Finish Button.

The standard user is “Admin” and the password is “zabbix”. Enter the username and password and click the Log in Button.

Once you have logged in, you will be redirected to the Zabbix administration dashboard.

From here you can customize your Zabbix installation and add new hosts. Your first step should be to change the current password. To do this, navigate to the user profile page by clicking on the profile icon in the top navigation.

Adding a new host to the Zabbix server

The process of adding a new host to the Zabbix server to monitor involves two steps.

First you need to install the Zabbix agent on the remote host and then add the host to the Zabbix server via the web interface.

Installation of the Zabbix agent

This tutorial assumes that the host computer is also using Ubuntu 18.04.

As with the Zabbix server installation, run the following commands to activate the Zabbix repository:

wget apt install ./zabbix-release_4.0-2+bionic_all.deb

Update the package index and install the Zabbix agent package:

sudo apt updatesudo apt install zabbix-agent

Zabbix supports two methods for encrypting server-client communication, preshared key (PSK) and certificate-based encryption. In this tutorial we use the Pre-Shared Keys (PSK) method to secure the connection between the server and the agent.

Use the following command to generate a preinstalled key and save it to a file:

openssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agentd.psk

The PSK key looks something like this:


Open the Zabbix agent configuration file:

sudo nano /etc/zabbix/zabbix_agentd.conf

search for Server IP address and change the default value to your Zabbix server IP:

### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '', '::', '::ffff:' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '' can be used to allow any IPv4 address.
#       Example: Server=,,::1,2001:db8::/32,
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=


Next, find the TSLConnect Option, uncomment it and put it on psk:

### Option: TLSConnect
#       How the agent should connect to server or proxy. Used for active checks.
#       Only one value can be specified:
#               unencrypted - connect without encryption
#               psk         - connect using TLS and a pre-shared key
#               cert        - connect using TLS and a certificate
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:

Find the TLSAccept Option, uncomment it and put it on psk:

### Option: TLSAccept
#       What incoming connections to accept.
#       Multiple values can be specified, separated by comma:
#               unencrypted - accept connections without encryption
#               psk         - accept connections secured with TLS and a pre-shared key
#               cert        - accept connections secured with TLS and a certificate
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:

Next, find the TLSPSKIdentity Option, uncomment it and put it on PSK 001 The value must be a unique string:

### Option: TLSPSKIdentity
#       Unique, case sensitive string used to identify the pre-shared key.
# Mandatory: no
# Default:
TLSPSKIdentity=PSK 001

Finally find the TLSPSKFile Option, uncomment it and set it to point to the pre-shared key created earlier:

### Option: TLSPSKFile
#       Full pathname of a file containing the pre-shared key.
# Mandatory: no
# Default:

When you’re done, save and close the file.

Start the Zabbix agent service and set it to start on boot with:

sudo systemctl start zabbix-agentsudo systemctl enable zabbix-agent

Next, you need to add a firewall rule that allows traffic from your Zabbix server on the TCP port 10050.

Assuming you use UFW
to manage your firewall and you want access from IP address you would run the following command:

sudo ufw allow proto tcp from to any port 10050

Set up a new host

After the agent is installed and configured on the remote host to be monitored, the next step is to register the host on the Zabbix server.

Log in to the Zabbix server web interface as an admin user:


Once inside, click the on the top navigation bar Configuration, and then Hosts

Next, click the blue one Create host Button in the top right corner of the screen and the host configuration page will open:

Enter the host name and IP address of the remote host computer that you want to monitor. Add the host to one or more groups by selecting the group from the list, or enter a nonexistent group name to create a new one. the Linux Servers Group is a good choice.

When you’re done, click Templates Tab. Select Template OS Linux and click on Add Link to add the template to the host.

Then click on the Encryption Tab. Select PSK for both Connections to host and Connections from host.

Set the PSK identity Worth to PSK 001, the value of the TLSPSKIdentity Option of the Zabbix agent that you configured in the previous step.

By doing PSK value add the key you generated for the Zabbix agent /etc/zabbix/zabbix_agentd.psk File.

Finally, to add the host, click the blue Add button button.


You have successfully installed the latest Zabbix on your Ubuntu system and learned how to add new hosts that you want to monitor.

You should check now Zabbix documentation
and learn more about how to configure and use Zabbix.

If you run into any problem or have any feedback, please leave a comment below.