AlmaLinuxRHEL Based

How To Install Zabbix on AlmaLinux 9

Install Zabbix on AlmaLinux 9

Zabbix is a powerful open-source monitoring solution that provides real-time monitoring of servers, networks, and applications. As IT infrastructure grows increasingly complex, the need for robust monitoring tools becomes essential. This guide will walk you through the step-by-step process of installing Zabbix 7 on AlmaLinux 9, ensuring that you can set up an efficient monitoring system for your environment.

Prerequisites

Before diving into the installation process, it’s crucial to ensure that your system meets the necessary requirements.

System Requirements

  • An AlmaLinux 9 server.
  • Minimum hardware specifications: 2 CPU cores, 4 GB RAM, and 20 GB of disk space.

Software Requirements

  • Apache Web Server
  • PHP (with necessary extensions)
  • MariaDB or MySQL

User Permissions

You will need root or sudo privileges to install the required packages and configure the system.

Knowledge Requirements

A basic understanding of the Linux command line will be beneficial as you navigate through the installation process.

Step 1: Update System Packages

Keeping your system updated is essential for security and stability. Start by updating your package manager:

sudo dnf update -y

This command ensures that all installed packages are up to date with the latest security patches and features.

Step 2: Install Required Software

The next step involves installing the necessary software components for Zabbix to function properly.

Install Apache Web Server

Apache is a widely-used web server that will serve the Zabbix frontend. Install it using the following command:

sudo dnf install httpd -y

Install PHP and Required Extensions

Zabbix requires PHP along with several extensions to operate effectively. Install PHP and its extensions with this command:

sudo dnf install php php-fpm php-mysqlnd php-ldap php-bcmath php-mbstring php-gd php-pdo php-xml -y

Install MariaDB

MariaDB will serve as the database backend for Zabbix. Install it by executing:

sudo dnf install mariadb-server mariadb -y

Step 3: Configure SELinux and Firewall

Security-Enhanced Linux (SELinux) can potentially block Zabbix from functioning correctly. Temporarily set SELinux to permissive mode:

sudo setenforce 0 && sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

This command will allow Zabbix to run without SELinux restrictions during installation. For a production environment, consider configuring SELinux policies properly instead of leaving it in permissive mode.

Configure Firewall Rules

Next, configure your firewall to allow HTTP traffic and Zabbix ports:

sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --add-port={10050,10051}/tcp --permanent
sudo firewall-cmd --reload

Step 4: Install Zabbix Repository

Zabbix provides a repository that simplifies the installation process. Add the repository for version 7 with this command:

rpm -Uvh https://repo.zabbix.com/zabbix/7.2/release/alma/9/noarch/zabbix-release-latest-7.2.el9.noarch.rpm

This command downloads and installs the Zabbix repository configuration file on your system.

Step 5: Install Zabbix Server and Agent

You can now install Zabbix server components along with the agent:

sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y

This command installs all necessary packages required for Zabbix to operate efficiently.

Step 6: Configure Database for Zabbix

Zabbix requires a dedicated database to store its configuration and monitoring data. Start by securing your MariaDB installation:

sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation

The `mysql_secure_installation` script will guide you through securing your MariaDB instance by setting a root password and removing anonymous users.

Create Zabbix Database and User

Create a new database and user specifically for Zabbix:

mysql -u root -p
CREATE DATABASE zabbixdb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

This creates a database named `zabbixdb` and a user `zabbixuser` with full privileges over that database. Replace `’password‘` with a strong password of your choice.

Step 7: Import Initial Schema and Data

The next step involves importing the initial schema into the newly created database:

zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbixuser -p zabbixdb

This command extracts and imports the SQL schema necessary for Zabbix to function correctly.

Step 8: Configure Zabbix Server

Edit the configuration file for the Zabbix server to connect it to your database:

sudo nano /etc/zabbix/zabbix_server.conf

You need to set the following parameters in this file:

  • DBName=zabbixdb: The name of your database.
  • DBUser=zabbixuser: The username created earlier.
  • DBPassword=password: The password for your database user.

Your configuration should look something like this:

# Database name
DBName=zabbixdb

# Database user
DBUser=zabbixuser

# Database password
DBPassword=password

Step 9: Start Zabbix Services

You are now ready to start the Zabbix services. Use these commands to start and enable them at boot:

sudo systemctl start zabbix-server zabbix-agent httpd php-fpm
sudo systemctl enable zabbix-server zabbix-agent httpd php-fpm

This ensures that all necessary services are running properly and will automatically start on boot.

Step 10: Configure Zabbix Web Interface

The final step is configuring the web interface. Open the PHP configuration file for Zabbix:

sudo nano /etc/php-fpm.d/zabbix.conf

You may want to set the timezone by adding or modifying this line:

;date.timezone = 
date.timezone = America/New_York

(Replace “America/New_York” with your appropriate timezone.) After saving changes, restart PHP-FPM:

sudo systemctl restart php-fpm

Acessing the Web Interface

You can now access the Zabbix web interface by navigating to http://your-server-ip/zabbix. Follow these steps in the setup wizard:

  • Select your language.
  • The wizard will check prerequisites; ensure everything is green.
  • Add database details as configured earlier (database name, user, password).
  • Select “Next” after confirming settings.
  • You can configure mail settings if needed; otherwise, skip this step.
  • Select “Next” again until you reach the final page, where you can log in using default credentials (Admin/ZABBIX).

Install Zabbix on AlmaLinux 9

Troubleshooting Tips

  • If you encounter issues starting services, check logs located in /var/log/zabbix/ for detailed error messages.
  • If you cannot access the web interface, ensure that Apache is running correctly using:
    sudo systemctl status httpd 

    If not running, check its logs located at /var/log/httpd/error_log.

  • If database connection errors occur, double-check your credentials in zabbix_server.conf file and ensure that MariaDB is running.
    Use:

    sudo systemctl status mariadb 
  • If SELinux is enabled after installation, configure proper policies instead of keeping it permissive.
  • If you face issues with PHP extensions not being recognized, ensure they are installed correctly and restart Apache using:
    sudo systemctl restart httpd 
  • If performance issues arise later on, consider tuning both PHP-FPM settings in /etc/php-fpm.d/www.conf and MariaDB configurations based on load requirements.

Congratulations! You have successfully installed Zabbix. Thanks for using this tutorial for installing the Zabbix open-source monitoring software on your AlmaLinux 9 system. For additional or useful information, we recommend you check the official Zabbix website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button