PART ONE: How to Install Zabbix on an Ubuntu 18.04 VPS or Dedicated Server

PART ONE: How to Install Zabbix on an Ubuntu 18.04 VPS or Dedicated Server


Zabbix is one of the best monitoring tool developed to monitor server availability, network devices, server performance, and other critical network components. It is a reliable open-source application that features a backend written in C and Java, and a frontend developed in PHP. This tutorial will help you install Zabbix on your Ubuntu 18.04 server, whether it is a VPS or dedicated server, to keep track of the status of your system, applications, and network devices. Ready? Let’s get started!

Before You Begin

To install the Zabbix server on Ubuntu 18.04 successfully, the following dependencies must be installed first:

Step 1 – Installing Apache

First, update your Ubuntu 18.04 server:

$ sudo apt update
$ sudo apt upgrade

Next, issue the command below to install Apache2

$ sudo apt install apache2

Once, Apache2 is installed, run the command below to open the file /etc/apache2/conf-enabled/security.conf and adjust the settings to configure the basic security.

$ sudo nano /etc/apache2/conf-enabled/security.conf

Find the line ServerTokens OS and change it to ServerTokens Prod. the ServerTokens directive determines what is returned as the response for server HTTP and has only six valid options namely: OS, Full, Minor, Minimal, Prod, and Major. Next, run the command below to open the /etc/apache2/apache2.conf file:

 $ sudo nano /etc/apache2/apache2.conf

Find ServerName and set it to and the ServerAdmin to

Note: Remember to replace with your Fully Qualified Domain Name (FQDN).

Once everything is done, save the changes and exit the nano editor. For these changes to take effect, restart your Apache web service:

$ sudo systemctl restart apache2

Next, execute the command below to enable the firewall and then allow HTTP and HTTPs:

$ sudo ufw enable
$ sudo ufw allow http
$ sudo ufw allow https

Step 2 – Installing PHP And The Required Modules

After installing Apache, you should install PHP and the modules required to enable Apache service to utilize PHP scripts. Issue the command below:

$ sudo apt-get -y install php php-pear php-cgi php-common libapache2-mod-php php-mbstring php-net-socket php-gd php-xml-util php-mysql php-gettext php-bcmath

You can execute the following command to confirm the PHP version:

$ sudo php -v

This will give you an output similar to the one below:

PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018ThePHPGroup
ZendEnginev3.2.0, Copyright (c) 1998-2018ZendTechnologies
withZendOPcachev7.2.5-0ubuntu0.18.04.1, Copyright (c) 1999-2018, byZendTechnologies

Next, execute the command below to enable conf php7.2-cgi:

$ sudo  a2enconf php7.2-cgi

You will be prompted to issue the command below to activate the new configuration:

$ sudo systemctl reload apache2

Once you reload Apache2, open the /etc/php/7.2/apache2/php.ini to set your correct timezone:

$ sudo /etc/php/7.2/apache2/php.ini

Find the line date.timezone and set it to your timezone. The timezones are set by location, and it’s easy to select one. For instance,

Date.timezone = "America/Toronto"

Then run the command below to restart Apache:

$ sudo systemctl restart apache2

Step 3 – Setting Up MariaDB

In this tutorial, we’ll use MariaDB as our database server. Follow the steps below to create the Database for a Zabbix user. Execute the command below to log in to the MariaDB command line:

$ sudo mysql -u root -p

Enter your root credentials and hit ENTER to access the MariaDB shell. Once you are on that command line, issue the command below to create the Zabbix user database: MariaDB [(none)]>

createdatabase zabbix;

Then, execute the following command to grant the new user all privileges: MariaDB [(none)]>

grant all privilegeson zabbix.* to zabbix@'localhost'identifiedby'password'

Note: Remember to replace the value ‘password’ with your preferred password.

Next, flush the privileges: MariaDB [(none)]>


Then, execute the command below to exit the database command line: MariaDB [(none)]>


Step 4 – Installing The Zabbix Server

To install the Zabbix server , first, execute the command below to add the Zabbix repository:

$ sudo wget

Then download the Zabbix installation files

$ sudo dpkg -i zabbix-release_3.4-1+bionic_all.deb

Now, update your system and install the Zabbix server modules:

$ sudo apt update
$ sudo apt install zabbix-agent zabbix-server-mysql php-mysql zabbix-frontend-php

You can now run the command below to confirm the status of Zabbix server:

$ sudo systemctl status zabbix-server

This will give you the following output:

● zabbix-server.service - Zabbix Server
   Loaded: loaded (/lib/systemd/system/zabbix-server.service; disabled; vendor preset: enabled)
   Active::active (running) since Wed 2018-10-2410:21:15 UTC; 2h 44min ago
  Process:23567 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)

Step 5 – Configuring The Zabbix Server

Now, open the file /etc/zabbix/zabbix_server.conf:

$ sudo /etc/zabbix/zabbix_server.conf

And confirm the following values are correctly configured:


If everything is okay, run the command below to restart the Zabbix server:

$ sudo systemctl restart zabbix-server

Next, run the command below:

$ sudo nano /usr/share/zabbix/include/classes/setup/CFrontendSetup.php

Find the directive always_populate_raw_post_data and set it to off. Besides, locate the lines:

publicfunctioncheckPhpAlwaysPopulateRawPostData() {
$current = ini_get('always_populate_raw_post_data');

Add the value ‘$current = -1‘ immediately after the line above to have the following result:

publicfunctioncheckPhpAlwaysPopulateRawPostData() {
    $current = ini_get('always_populate_raw_post_data');
    $current = -1;

Save the changes and exit the nano editor. Run the command below to open the file /etc/php/7.2/apache2/php.ini:

$ sudo nano /etc/php/7.2/apache2/php.ini

Once the file opens, locate and set the PHP requirements as follows:

max_execution_time = 300
max_input_time = 300
post_max_size = 16M

Next, open the file /etc/zabbix/zabbix_agentd.conf and adjust the settings to enable Zabbix agent tocontrol the Zabbix server.

$ sudo nano /etc/zabbix/zabbix_agentd.conf

Set the following:

Replace with your valid domain name. Now, start and enable the Zabbix server:

$ sudo systemctl start zabbix-server
$ sudo systemctl enable zabbix-server

The last thing is to allow ports 5000 and 5001

$ sudo ufw allow proto tcp fromany to any port 10050,10051


That is It! You have successfully installed Zabbix on your Ubuntu 18.04 VPS or Dedicated server. Part two of this article will show you how to complete the server settings for your Zabbix web interface.

Check out these top 3 Linux hosting services

$1.79 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing

How to install Zabbix on Ubuntu 18.04 [PART TWO]

This tutorial is compiled to help you install Zabbix; a powerful server monitori
5 min read
David Malcom
David Malcom

How to Switch between PHP Versions on an Ubuntu 22.04 VPS or Dedicated Server

As a PHP developer, you may bump into applications that require older versions.
2 min read
Kennedy Mbuvi
Kennedy Mbuvi

How to Install the LEMP (Linux, Nginx, MySQL, PHP) Stack on an Ubuntu 18.04 VPS or Dedicated Server

This tutorial walks you through the process of installing Nginx, MySQL, and PHP
4 min read
Mark Armistead
Mark Armistead

How To Install Apache, MySQL & PHP on an Ubuntu 18.04 VPS or Dedicated Server

This article shows users how to setup PHP, Apache web server and MySQL database
4 min read
Idan Cohen
Idan Cohen
Marketing Expert provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top