WindowsMacSoftwareSettingsSecurityProductivityLinuxAndroidPerformanceConfigurationApple All

How to Install and Configure Zabbix on Linux

Edited 3 weeks ago by ExtremeHow Editorial Team

MonitoringZabbixSystem AdministrationNetwork MonitoringServersAlertsConfigurationDashboardsPerformanceTools

How to Install and Configure Zabbix on Linux

This content is available in 7 different language

Zabbix is an open-source monitoring tool designed to monitor and track the status of various network services, servers, and other network hardware. It provides monitoring metrics such as CPU load, network usage, and disk space consumption. Zabbix also provides notifications based on customizable alerts for certain thresholds.

This guide will introduce you to the process of installing and configuring Zabbix on a Linux-based system. The instructions will cover the steps required to get the Zabbix server up and running, as well as how to set up the Zabbix agent on a client machine to collect monitoring data.

Prerequisites

Before installing Zabbix, make sure your system meets the following requirements:

Step 1: Update your system

Before installing Zabbix, it is important to update the package repository and installed packages to ensure you have the latest versions. Run the following commands depending on your Linux distribution:

For Ubuntu / Debian

sudo apt update
sudo apt upgrade -y

For CentOS / RHEL

sudo yum update

Step 2: Install Apache, MySQL and PHP

Zabbix requires a web server, a database, and PHP to work. We will use Apache as the web server and MySQL (or MariaDB) as the database. Run the following commands to install these packages:

For Ubuntu/Debian

Install Apache:

sudo apt install apache2 -y

Install the MySQL server:

sudo apt install mysql-server -y

Secure MySQL Installation:

sudo mysql_secure_installation

Install PHP and required extensions:

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

For CentOS / RHEL

Install Apache:

sudo yum install httpd -y

Install MariaDB (use MySQL if desired):

sudo yum install mariadb-server -y

Start and secure MariaDB:

sudo systemctl start mariadb
sudo mysql_secure_installation

Install PHP and required extensions:

sudo yum install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysqlnd -y

Step 3: Install Zabbix repository

The next step is to install the Zabbix repository on your system. This is necessary as Zabbix packages may not be available in the default repository. Run the appropriate command for your system:

For Ubuntu/Debian

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1%2Bubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo apt update

For CentOS / RHEL

sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
sudo yum clean all

Step 4: Install Zabbix server, frontend and agent

Now it's time to install the Zabbix server, web frontend, and agent. Make sure you have installed the Zabbix repository before running these commands.

For Ubuntu/Debian

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent -y

For CentOS / RHEL

sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-apache-conf -y

Step 5: Create the Zabbix database

The Zabbix server needs a database to store its data. You must create the database and configure Zabbix to use it.

Log into the MySQL shell:

mysql -u root -p

Create the Zabbix database:

CREATE DATABASE zabbix character set utf8mb4 collate utf8mb4_bin;

Create a database user for Zabbix:

CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';

Grant privileges to the Zabbix user:

GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';

Reload the privilege tables and exit:

FLUSH PRIVILEGES;
EXIT;

Step 6: Configure the Zabbix server

After the database is ready, you need to import the initial schema and configure the Zabbix server.

Import the initial schema

Run the following command to import the schema:

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix

Note: You will be asked for the password you set when creating the zabbix user in MySQL.

Edit the Zabbix configuration file

Open the Zabbix server configuration file:

sudo nano /etc/zabbix/zabbix_server.conf

Find the following lines and update them accordingly:

Set DBName:

DBName=zabbix

Set up DBUser:

DBUser=zabbix

Set DBPassword (remove the comment and set your own password):

DBPassword=password

Step 7: Configure PHP for Zabbix frontend

Edit the PHP configuration file for Zabbix to make sure it meets the minimum requirements.

For Ubuntu / Debian

Edit php.ini for Apache:

sudo nano /etc/zabbix/apache.conf

Set the correct time zone (replace 'your/timezone' with your actual time zone, for example, 'America/New York'):

php_value date.timezone Europe/Riga

For CentOS / RHEL

Open the php.ini file:

sudo nano /etc/php.ini

Set the correct time zone:

date.timezone = Europe/Riga

Step 8: Start and enable Zabbix server and Apache

After installing and configuring the required components, you need to start the Zabbix server and frontend processes.

Start and enable the Zabbix server

sudo systemctl restart zabbix-server zabbix-agent httpd
sudo systemctl enable zabbix-server zabbix-agent httpd

Start and enable Apache (for CentOS and RHEL)

sudo systemctl start httpd
sudo systemctl enable httpd

Start and enable Apache (for Ubuntu and Debian)

sudo systemctl restart apache2
sudo systemctl enable apache2

Step 9: Access the Zabbix web interface

With the Zabbix server running, you can now access the Zabbix web interface to complete the configuration via your web browser. The interface is typically accessed on port 80.

Open your browser and go to the following URL:

http://your_server_ip/zabbix

You will see the Zabbix welcome screen. Click "Next Step" to continue.

Configuration Details

On the configuration page, configure the database connection details using the database we set up earlier. If it is on the same machine as the server, use "localhost" as the database host.

Click “Next Step” to continue.

Server Details

Configure the frontend settings, then proceed to the next step.

Click "Next Step" to go to the "Finish Installation" page.

Finish the installation

During the final step, confirm all details are correct, then click "Finish" to complete the installation.

Once Zabbix is installed, log in to your dashboard using the default credentials:

Step 10: Set up the Zabbix agent

The Zabbix agent is a component used to collect data from the monitored device; it then sends this data back to the server. Here's how to set up the Zabbix agent on the monitored host:

Install Zabbix Agent

For Ubuntu / Debian

sudo apt install zabbix-agent -y

For CentOS / RHEL

sudo yum install zabbix-agent -y

Configure the Zabbix agent

Edit the Zabbix agent configuration file:

sudo nano /etc/zabbix/zabbix_agentd.conf

Modify the following parameters:

Set the server parameter to your Zabbix server IP address:

Server=your_zabbix_server_ip

Set the ServerActive parameter (optional):

ServerActive=your_zabbix_server_ip

Set the hostname parameter to the name of the host to be monitored:

Hostname=my-monitored-host

Start and enable the Zabbix agent

Start the Zabbix agent and enable it to start at boot time:

sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent

Conclusion

You have successfully installed and configured the Zabbix server and agent. Zabbix is now running on your system, ready to monitor your network infrastructure. With its easy setup and powerful features, Zabbix can help keep your IT infrastructure running smoothly by providing real-time monitoring, alerts, and analysis of all your critical systems and applications.

Explore Zabbix's detailed documentation to get the most out of its features, and consider configuring additional agents and host monitoring to suit your network's needs.

If you find anything wrong with the article content, you can


Comments