Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual machines and cloud services. Zabbix provides monitoring metrics, among others network utilization, CPU load and disk space consumption. Zabbix has a rich set of features to enable users to monitor more than just hosts, offering great flexibility to administrators when it comes to choosing the most suitable option for each situation.
Zabbix uses XML based template which contains elements to monitor. The backend of Zabbix is written in C programming and PHP is used for the web frontend. Zabbixcan send you alertsto notify the different events and issues based on metrics and thresholds defined for your IT environment. It supports agent-based and agentless monitoring. But Zabbix agents installation can help you to get detailed monitoring e.g. CPU load, network, disk space utilization.
As of the writting of this article, the latest Zabbix version is 6.0. In this guide, we will learn how to install and configure Zabbix on Ubuntu 20.04.
Related content:
- How to Install and Configure Zabbix Server 5 on Rocky Linux/Alma Linux 8
- How to Add Host in Zabbix Server to Monitor
- How to Install Zabbix Agent on Rocky Linux/Alma Linux 8
- How To Install and Configure Zabbix Agent on Ubuntu 20.04
Table of Content
- Ensure that the server is up to date
- Install Mariadb
- Create mysql user for zabbix
- Install PHP and required PHP modules
- Install Apache web server
- Edit PHP and php-fpm configs for Zabbix
- Start and enable php-fpm service
- Install Zabbix
- Configure SELinux and firewall
- Complete Zabbix Installation
1. Ensure that the server packages are up to date
Before proceeding, let us make sure that our server packages are up to date with this command:
sudo apt update
sudo apt -y upgrade
Let us also install some common packages that we will need
sudo apt install -y vim
2. Install Mariadb
Zabbix requires mysql to function. Mariadb is a popular Opensource relational management system. We will use it in this guide. It is available in the default repositories as mariadb-server
. For a detailed guide check out How to install and Configure Mariadb 10 in Ubuntu 20.04.
Install Mariadb :
sudo apt install -y mariadb-server
Once mariadb is installed, you can confirm the details using this command:
$ apt-cache policy mariadb-server mariadb-server: Installed: 1:10.3.32-0ubuntu0.20.04.1 Candidate: 1:10.3.32-0ubuntu0.20.04.1 Version table: *** 1:10.3.32-0ubuntu0.20.04.1 500 500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages 500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages 100 /var/lib/dpkg/status 1:10.3.22-1ubuntu1 500 500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
The Service will be started by default. Confirm the status with this command:
$ sudo systemctl status mariadb sudo: unable to resolve host ubuntu0srv.citizix.com: No address associated with hostname ● mariadb.service - MariaDB 10.3.32 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-02-23 13:05:12 UTC; 21s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 11362 (mysqld) Status: "Taking your SQL requests now..." Tasks: 31 (limit: 4624) Memory: 64.3M CGroup: /system.slice/mariadb.service └─11362 /usr/sbin/mysqld Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: information_schema Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: mysql Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: performance_schema Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: Phase 6/7: Checking and upgrading tables Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: Processing databases Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: information_schema Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: performance_schema Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: Phase 7/7: Running 'FLUSH PRIVILEGES' Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11401]: OK Feb 23 13:05:12 ubuntu0srv.citizix.com /etc/mysql/debian-start[11467]: Checking for insecure root accounts.
To ensure that mariadb starts on boot, enable it with this systemd command:
sudo systemctl enable mariadb
Once the mysql service is running, you need to secure it. Mysql provides a commandline utility that will do that:
sudo mysql_secure_installation
The above command will take you through prompts to secure and set a root password for the mysql instance.
To confirm the version of MariaDB installed, run the command:
$ mysql -V mysql Ver 15.1 Distrib 10.3.32-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Create mysql user for Zabbix
We are going to create a dedicated user for zabbix. Check out this guide on managing mysql permissions here.
Connect to mysql server:
|
|
After Supplying your root password, enter the following to the mysql prompt:
|
|
Save the username, db name and password, we will need them later.
Now that we have configured our mysql connection, let’s go to the next section where we install and configure PHP.
Install PHP and required php modules
Zabbix server uses PHP. We need to install and configure PHP for zabbix to work.
To install PHP and the required PHP modules for Zabbix installation:
|
|
Check php version
|
|
For more info on setting up PHP and Apache, check out this guide How to install and set up PHP and Apache(LAMP stack) on Ubuntu 20.04.
Install Apache Web Server
Next, let us install Apache in our system. Use this command to install Apache web server.
|
|
Apache 2 will be started by default. Check the status using this command:
|
|
Active: active (running)
indicate that the service is now up and running.
To enable the service on boot, use this command:
|
|
Edit PHP and php-fpm Config for Zabbix
Update the php config to optimize for Zabbix installation.
Open the php ini file
|
|
Then modify these settings to the values shown. Update the timezone to fit yours.
|
|
Next let us edit the php-fpm settings.
|
|
Then update these values
|
|
Save the changes and exit the file.
Start and enable php-fpm service
The php-fpm service is started by default. Confirm by checking the status:
|
|
Enable the service to start on boot
|
|
At this point, we have successfully installed the LAMP stack. We can now install Zabbix
Install Zabbix
Zabbix is not available in the default Ubuntu repositories but it provides a repository.
First, download and Install the zabbix repository
|
|
Once the repository is installed, install the Zabbix server, Zabbix agent, and the associated Zabbix packages.
|
|
Next, import the database schema:
|
|
When prompted for a password, provide the Zabbix user’s password.
Edit Zabbix configuration file and update the db credentials
|
|
Ensure that the DBName, DBUser, DBPassword values reflect the values you provided for your database
|
|
Save the changes and exit the configuration file.
To apply all the changes made, restart all the services as shown
|
|
Additionally, consider enabling them on startup.
|
|
Configure Firewall
If you have ufw firewall installed and enabled, enable web and Zabbix ports
|
|
Complete Zabbix Installation
To complete the installation, launch your browser, and go to this URL: http://server-ip/zabbix
The first page that greets you is the Zabbix welcome page that boldly displays the version you are installing. Select the installation language and click on the ‘Next step’ button.
In the next page you get a list of prerequisites, scroll all the way down and ensure all the prerequisites get the ‘OK’ label in the last column. It’s mandatory that all the requirements are satisfied. Then hit the ‘Next step’ button.
On the ‘Configure DB Connection’ page. Fill out your database details. For the database port, leave it at 0. The press ‘Next step’.
Then specify your server’s name, confirm your time zone and feel free to select your preferred theme. Then press ‘Next step’.
Confirm all the settings and if all looks well, press on ‘Next step’ to finalize the installation.
If all the settings you provided are correct, you will get a congratulatory message notifying you of the successful setup of Zabbix’s front end. Press on the ‘Finish’ button.
This directs you to the Zabbix login page. Log in with the following credentials:
Username: Admin
Password: zabbix
Then click on ‘Sign in’ to access the Zabbix dashboard. You can change the password later for added security, so don’t worry about that.
Finally, you will get access to Zabbix’s dashboard.
That is it! We have successfully installed the Zabbix monitoring tool on Ubuntu 20.04.