How To Install & Configure Zabbix on Ubuntu
How to Install Zabbix Server on Ubuntu 20.04
Zabbix is an open-source web-based monitoring tool for monitoring a diverse range of IT components. This includes network devices such as servers, virtual machines, and applications. It provides a plethora of monitoring metrics such as network utilization, CPU load, and disk utilization. This makes troubleshooting easier when the system is behaving abnormally. You can visualize the performance metrics in the form of graphs, screens, maps, and overviews.
In this guide, we show you how to install Zabbix server 5.4 on Ubuntu 20.04 LTS.
https://www.zabbix.com/download?zabbix=5.0&os_distribution=ubuntu&os_version=20.04_focal&db=mysql&ws=apache
Prerequisites
Before getting started, ensure you have a running Ubuntu 20.04 instance with sudo privileges. Also, ensure you are connected to a stable internet connection.
Step 1: Install and Setup Apache
In this step, we install the Apache webserver. First, update all Ubuntu repository lists and install Apache packages by running the command below:
$ sudo apt update
Now Install apache using the following command:
$ sudo apt install apache2
Apache service will start by default after installation. Incase not started run the following command to start apache2.
$ sudo systemctl start apache2
To enable apache2 on boot, type:
$ sudo systemctl enable apache2
Step 2: Install PHP and associated modules
The front-end of Zabbix is written in PHP and because of that we need to install PHP. Already, Ubuntu provides in its repositories which by default is PHP 7.4. 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 verify the version of PHP installed 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 be sure to set the right time zone according to your locale.
nano /etc/php/7.4/apache2/php.ini
memory_limit= 512M
upload_max_filesize= 16M
post_max_size= 16M
max_execution_time= 300
max_input_time= 300
max_input_vars= 10000
date.timezone = Asia/karachi
For the changes to kick in, restart the Apache service
$ sudo systemctl restart apache2
Step 3: Install MariaDB database server
Next, we are going to install MariaDB database as our preferred database server for storing user data and storing other metrics.
Install MariaDB Server packages by running the following command:
$ sudo apt install mariadb-server
Once installed, be sure to harden your database server using the command:
$ sudo mysql_secure_installation
Begin by setting the root password.
Enable at boot and start mariadb server:
systemctl enable mariadb && systemctl start mariadb
So, To setup a root password and secure mariadb server, please follow
https://mariadb.com/kb/en/mysql_secure_installation/
you may skip secure installation step
harden mariadb instance
Step 4: Create Zabbix user and database
Next, we create a database user for the Zabbix server. You will need to first 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:
# mysql -uroot -p
password
mysql>
create database zabbix character set utf8 collate utf8_bin;
mysql>
create user zabbix@localhost identified by 'password';
mysql>
grant all privileges on zabbix.* to zabbix@localhost;
FLUSH
PRIVILEGES;
mysql>
quit;
Step 5: Enable Zabbix repository
https://www.zabbix.com/documentation/current/manual/installation/upgrade/packages/debian_ubuntu
To add Zabbix repository to your system, first download the Zabbix release Debian package using the wget command.
We are using Zabbix 5.4 version which is latest at the time of writing this guide.
Then, to enable the Zabbix repository, type:
dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb
To synchronize 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 that provides MySQL support, the zabbix-frontend-php package that provides a web interface for the server, alongside zabbix-agent for shipping metrics and the zabbix-apache-conf package for Apache.
$ sudo apt install zabbix-server-mysql zabbix-frontend-php
zabbix-apache-conf zabbix-sql-scripts zabbix-agent
Step 7: Configure Zabbix server
With Zabbix installed, some additional tweaks 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 configurations as per your database user settings
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password
Then load the default schema of the Zabbix database.
Cd /usr/share/doc/zabbix-sql-scripts/mysql
$ zcat create.sql.gz | mysql -u zabbix -p zabbix
You will be required to provide your password, so go ahead and provide it.
Now, enable the Zabbix service to start on system boot and restart service to apply the new settings.
systemctl restart zabbix-server zabbix-agent
apache2
# systemctl enable zabbix-server zabbix-agent
apache2
You can verify the status of Zabbix using the command:
$ sudo systemctl status zabbix-agent.service
systemctl status zabbix-server.service
Zabbix also creates its own Apache configuration file /etc/zabbix/apache.conf and creates a link to the Apache configuration directory.
Change timezone and uncomment
Use the command below to restart Apache services.
https://www.php.net/manual/en/timezones.asia.php
$ sudo systemctl restart apache2
Also verify that Apache is running:
$ sudo systemctl status apache2
Your system is now ready for Zabbix installation.
Step 6: Configure the firewall
If you are behind a firewall, you need to allow Zabbix ports 10050 and 10051 and HTTP. Run the commands below 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: Complete Zabbix installation on a browser
We are all set now. The only thing remaining is to complete the installation on a web browser. So, launch your browser and navigate to the address shown:
http://server-ip/zabbix
mysql -uroot -p'password' zabbix -e "set global innodb_strict_mode='OFF';"
Enter the user name Admin with password zabbix
https://www.zabbix.com/documentation/current/manual/installation/upgrade/packages/debian_ubuntu
Comments
Post a Comment