Install Zabbix Server on Ubuntu 20.04

Zabbix is an open source web-based monitoring tool for monitoring a wide range of IT components. This includes network devices such as servers, virtual machines, and applications. Provides a host of monitoring metrics such as network utilization, CPU load, and disk utilization. This makes it easier to troubleshoot when the system behaves abnormally. You can visualize performance metrics in the form of graphs, screens, maps, and overviews.

In this guide, we show you how to install Zabbix Server 5.0 on Ubuntu 20.04 LTS.

Prerequisites

Before you begin, make sure you have a running Ubuntu 20.04 instance with sudo privileges. Also, make sure you are connected to a stable internet connection.

Step 1: Install and configure Apache

In this step, we install the Apache web server. First, update all Ubuntu repository lists and install Apache packages by running the following command:

$ sudo apt update 

Now Install Apache using the following command:

$ sudo apt install apache2 

The Apache service will be started by default after installation. In case it has not started, run the following command to start apache2.

$ sudo systemctl start apache2  

To enable apache2 at boot, type:

$ sudo systemctl enable apache2

Step 2 – Install PHP and associated modules

The Zabbix front-end is written in PHP and that's why we need to install PHP. Ubuntu already provides PHP 7.4 by default in its repositories. This is what we are going to use for this guide.

To install PHP packages, use the following apt command:

$ sudo apt install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql

You can check the installed PHP version using the following command:

$ php -v

Once the installation is complete, head over to the PHP configuration directory and edit the /etc/php/7.4/apache2/php.ini file. Modify the parameters as shown and make sure to set the correct time zone for your location.
$ sudo vim /etc/php/7.4/apache2/php.ini
memory_limit 256M 
upload_max_filesize 16M 
post_max_size 16M 
max_execution_time 300 
max_input_time 300 
max_input_vars 10000 
date.timezone="Africa/Nairobi"
For the changes to take effect, restart the Apache service.
$ sudo systemctl restart apache2
Step 3: Install the MariaDB database server
Next, we will install the MariaDB database as our preferred database server for storing user data and storing other metrics.
Install the MariaDB server packages by running the following command:
$ sudo apt install mariadb-server
Once installed, make sure to harden your database server using the command:
$ sudo mysql_secure_installation
Start by setting the root password.
Then type ' Y ' for all remaining prompts:
Step 4: Create the Zabbix User and Database
Next, we create a database user for the Zabbix server. You will first need to log in to the MariaDB instance:
$ sudo mysql -u root -p
Create a Zabbix user and database as shown and grant all privileges to the user as follows:
CREATE DATABASE zabbix_db character set utf8 collate utf8_bin;
CREATE USER 'zabbix_user'@'localhost' IDENTIFIED BY ' P@ssword321 ';
GRANT ALL PRIVILEGES ON zabbix_db.* TO 'zabbix_user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Step 5: Enable the Zabbix repository
To add the Zabbix repository to your system, first download the Zabbix release Debian package using the wget command.
$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
We are using Zabbix Version 5.01 which is the latest at the time of writing this guide.
Then, to enable the Zabbix repository, type:
$ sudo dpkg -i zabbix-release_5.0-1+focal_all.deb
To sync the newly added repository with the system, update the package lists
$ sudo apt update
Step 6: Install Zabbix Server on Ubuntu 20.04
To install the Zabbix server, we will install the zabbix-server-mysql package which provides MySQL support , the zabbix-frontend-php package which provides a web interface to the server, along with zabbix-agent for push metrics and zabbix-apache- conf package for apache.
$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf
Step 7 – Configure Zabbix Server
With Zabbix installed, some additional settings are required. The configuration file is located at /etc/zabbix/zabbix_server.conf path. So open the file.
$ sudo vim /etc/zabbix/zabbix_server.conf
Update your database settings based on your database user settings
DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=P@ssword321
Then load the default Zabbix database schema.
$ cd /usr/share/doc/zabbix-server-mysql
$ zcat create.sql.gz | mysql -u zabbix_user -p zabbix_db
You will be prompted to provide your password, so please do so.
Now, enable the Zabbix service to start on system boot and restart the service to apply the new settings.
$ sudo systemctl enable zabbix-server 
$ sudo systemctl restart zabbix-server
You can check the status of Zabbix using the command:
$ sudo systemctl status zabbix-server

Zabbix also creates its own Apache configuration file /etc/zabbix/apache.conf and creates a link to the Apache configuration directory. Use the following command to restart Apache services.
$ sudo systemctl restart apache2
Also check that Apache is running:
$ sudo systemctl status apache2

our system is now ready for the Zabbix installation.
Step 6: Configure the firewall
If you are behind a firewall, you must allow Zabbix ports 10050 and 10051 and HTTP. Run the following commands to allow the ports:
$ sudo ufw allow 80/tcp
$ sudo ufw allow 10050/tcp
$ sudo ufw 10051
Then reload your firewall service to apply the changes made above:
$ sudo ufw reload
Step 7 - Full Installation of Zabbix in a Browser
We are all ready now. The only thing left is to complete the installation in a web browser. So, start your browser and navigate to the address shown:
http://server-ip/zabbix
You get a welcome page shown below. Simply click Next to continue to the next step.
Verify that the server meets all the prerequisites and click the Next Step button.
In the next step, provide the database credentials you provided when creating a database for Zabbix in Step 4 and click the Next Step button.
To get the Zabbix server details, provide the hostname and IP address of your server, then click the 'Next Step' button again.
You will get a summary of the pre-installation as shown. Make sure all the configuration parameters are correct, and then click the Next Step button.
Once the installation has completed successfully, you should see the following screen:


Click the Finish button. You will be directed to the Zabbix front-end login page shown below:

Login with the following default credentials:

Username: Admin
Password: zabbix


After successful login, you will see the Zabbix Dashboard as shown below:


conclusion
And that is! Now you can start adding your hosts to the monitoring server to keep an eye on their performance. In this guide, we show you how to install Zabbix server on Ubuntu 20.04 system.

No comments

Powered by Blogger.