Zabbix is open-source monitoring software. It offers real-time monitoring of servers, virtual machines, network devices, and web applications. If you are not interested following text based tutorial, please watch following video which will help you to set up zabbix quickly.
This tutorial will take you through the steps to install and configure Zabbix server on an Ubuntu 19.04 machine.
To follow this guide, you will need one Ubuntu 19.04 installed on either physical or virtual machine.
Setting Timezone
Configure correct timezone on your Ubuntu machine using the following command:
sudo timedatectl set-timezone Asia/Karachi
Installing Apache, MySQL, PHP
You will need to install apache, mysql and php prior to installing zabbix by executing following command:
sudo apt -y install apache2 mysql-server php
Installing Zabbix Repository
Zabbix is available in Ubuntu's package manager, but its outdated and we need to install latest release so using the official Zabbix repository to install the latest stable version.
First check latest stable release from here and then download and install the appropriate repository configuration package:
wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-1%2Bbionic_all.deb
sudo dpkg -i zabbix-release_4.2-1+bionic_all.deb
sudo apt update
Installing Zabbix
Type the following commands to install zabbix server and its agent:
sudo apt -y install zabbix-server-mysql zabbix-frontend-php
sudo apt install zabbix-agent
Configuring MySQL
We have installed MySQL server in earlier step so we need to configure it by executing the following commands:
sudo mysql -u root -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'P@ssw0rd';
flush privileges;
exit
Run the following command to set up the schema and import the data into the zabbix database. Use zcat since the data in the file is compressed.
sudo zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -p zabbix
Enter the password for the zabbix MySQL user that you configured when prompted.
In order for the Zabbix server to use this database, you need to set the database password in the Zabbix server configuration file. Open the configuration file in your preferred text editor.
sudo nano /etc/zabbix/zabbix_server.conf
Search for the following section of the file:
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
You need to uncomment and set the DBPassword value in the file to the password for your database user like below:
DBPassword=Your_Zabbix_DB_User_Password
Save and close
zabbix_server.conf
by pressing CTRL+X
, followed by Y
and then ENTER
if you're using nano
.Configuring PHP
The Zabbix installation process created an Apache configuration file that contains these settings. It is located in the directory /etc/zabbix and is loaded automatically by Apache. You need to make a small change to this file, so open it up with the following:
sudo nano /etc/zabbix/apache.conf
Uncomment the timezone line, highlighted in the red color, and change it to your timezone.
<IfModule mod_php5.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 Asia/Karachi
</IfModule>
<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 Asia/Karachi
</IfModule>
Save and close
apache.conf
by pressing CTRL+X
, followed by Y
and then ENTER
if you're using nano
.Restart Apache to take changes into effect.
sudo systemctl restart apache2
You can now start zabbix server by executing the following commands:
sudo systemctl start zabbix-server
sudo systemctl enable zabbix-server
sudo systemctl status zabbix-server
Configuring Zabbix
The zabbix web interface requires some initial setup before you can use it. Launch your browser and go to the address http://zabbix_server_ip_address/zabbix or http://zabbix_server_hostname/zabbix. On the first page, you will see a welcome message like below.
Click Next step to continue.
On the next page, you will see the table that lists all of the prerequisites to run Zabbix. Scroll down and look at all of the prerequisites and be sure all of the values in this table must be OK.
Click Next step to proceed.
The following page asks for database connection information. Provide the MySQL credentials you configured earlier and click Next step to proceed.
On the following page, you can leave the options at their default values if you have only one zabbix server in your environment and click Next step to continue.
The follwoing page will show the pre-installation summary so you can confirm everything is correct.
Click Next step to continue.
This process creates the configuration file /usr/share/zabbix/conf/zabbix.conf.php which you could back up and use in the future.
Click Finish to proceed to the login page.
The default user is Admin and the password is zabbix.
After successful login, you will see zabbix default dashboard page.
Wrapping up
In this guide, you learned how to set up zabbix server on Ubuntu 19.04 which will help you monitor the state of your servers and applications.