Best Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server

Posted on

Best Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server

Best Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server

This tutorial provides a comprehensive Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server. We’ll walk you through the process to install and configure Zabbix 6.4 on Ubuntu 22.04 and access the Zabbix dashboard via a web interface. Zabbix 6.4 is the latest release of the powerful Zabbix monitoring solution, packed with improved features and capabilities. Follow this step-by-step guide to get your Zabbix 6.4 server up and running on Ubuntu 22.04.

Before diving into the Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server, let’s ensure we have the necessary prerequisites in place.

Requirements for Zabbix 6.4

First and foremost, you’ll need access to your Ubuntu 22.04 server as a non-root user with sudo privileges. It’s also crucial to set up a basic firewall for security. You can refer to this guide: Initial Server Setup with Ubuntu 22.04.

Secondly, since we’ll be installing Zabbix using a LAMP stack (Linux, Apache, MySQL/MariaDB, PHP), make sure you have a LAMP stack already installed. If not, you can find detailed instructions here: Install LAMP Stack on Ubuntu 22.04.

Once you’ve met these requirements, you’re ready to begin the Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server.

Step 1 – PHP Configuration For Zabbix 6.4

Zabbix relies on several PHP extensions to function correctly. Install these extensions using the following command:

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

Next, you need to modify the php.ini file to adjust PHP settings for optimal Zabbix performance. Open the php.ini file using your preferred text editor (we’ll use vi in this example):

sudo vi /etc/php/8.1/apache2/php.ini

Within the php.ini file, locate the following lines and adjust their values as shown:

memory_limit = 256M
upload_max_filesize = 16M
post_max_size = 16M
max_execution_time = 300
max_input_time = 300

Also, find the following lines and uncomment them (remove the semicolon at the beginning) and set their values:

max_input_vars = 10000
date.timezone = Etc/UTC

Note: Remember to set the correct timezone for your location.

After making these changes, save and close the php.ini file.

Finally, restart the Apache web server to apply the PHP configuration changes:

sudo systemctl restart apache2

Step 2 – MariaDB for Zabbix 6.4 (Create Database User)

Now, let’s create a dedicated database and user account for Zabbix within MariaDB.

Log in to your MariaDB console as the root user:

sudo mysql -u root -p

Once inside the MariaDB shell, create a database named zabbixdb with the appropriate character set and collation:

**MariaDB [(none)]>** CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;

Next, create a new user named zabbixuser with a strong password:

**MariaDB [(none)]>** CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'password';

Grant all necessary privileges to the zabbixuser for the zabbixdb database and enable the log_bin_trust_function_creators option:

**MariaDB [(none)]>** GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixuser'@'localhost' WITH GRANT OPTION;
**MariaDB [(none)]>** set global log_bin_trust_function_creators = 1;

Finally, flush the privileges to apply the changes and exit the MariaDB console:

**MariaDB [(none)]>** FLUSH PRIVILEGES;
**MariaDB [(none)]>** EXIT;

Step 3 – Install Zabbix 6.4 on Ubuntu 22.04 Server

To initiate the Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server, you need to add the Zabbix repository. Visit the Zabbix Downloads page and select your desired version and operating system. The following commands add the Zabbix 6.4 repository:

sudo wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb

After adding the repository, update the system’s package lists:

sudo apt update

Now, install the Zabbix server, frontend, and agent using the following command:

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

Step 4 – Manage Zabbix Server Service on Ubuntu 22.04

Once the installation is complete, start and enable the Zabbix server service to ensure it runs automatically on boot:

sudo systemctl start zabbix-server
sudo systemctl enable zabbix-server

Verify that the Zabbix server is active and running:

sudo systemctl status zabbix-server

The output should indicate that the service is active (running).

**Output**
● zabbix-server.service - Zabbix Server
     Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled)
     Active: **active** (**running**) since Wed 2023-07-19 09:41:06 UTC; 11s ago
   Main PID: 16230 (zabbix_server)
      Tasks: 1 (limit: 4575)
     Memory: 3.2M
        CPU: 50ms
     CGroup: /system.slice/zabbix-server.service
             └─16230 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
...

Step 5 – Import Zabbix 6.4 Database Schema

At this stage, you need to import the Zabbix database schema into the zabbixdb database.

Execute the following command to import the schema:

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbixuser -p zabbixdb

Enter the password for the zabbixuser when prompted.

After importing the database schema, disable the log_bin_trust_function_creators option for enhanced security. Log in to the MariaDB console and execute the following commands:

sudo mysql -u root -p
**MariaDB [(none)]>** set global log_bin_trust_function_creators = 0;
**MariaDB [(none)]>** quit;

Step 6 – Zabbix 6.4 Configuration on Ubuntu 22.04

Now, let’s configure the Zabbix server to connect to the newly created database. Open the Zabbix server configuration file:

sudo vi /etc/zabbix/zabbix_server.conf

Locate the following lines and uncomment them, replacing the placeholders with your database credentials:

DBHost=localhost
DBName=zabbixdb
DBUser=zabbixuser
DBPassword=password

Save and close the file.

Restart the Zabbix server and Apache web server to apply the configuration changes:

sudo systemctl restart zabbix-server
sudo systemctl restart apache2

Step 7 – Configure Zabbix 6.4 Agent on Ubuntu 22.04 Server

Configure the Zabbix agent on your Ubuntu 22.04 server to allow it to be monitored by the Zabbix server. Open the Zabbix agent configuration file:

sudo vi /etc/zabbix/zabbix_agentd.conf

Find the following lines and modify them as shown:

Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix Server

Save and close the file.

Start and enable the Zabbix agent service:

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

Verify that the Zabbix agent is running:

sudo systemctl status zabbix-agent

The output should show that the service is active (running).

**Output**
● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
     Active: **active** (**running**) since Wed 2023-07-19 09:40:52 UTC; 6min ago
   Main PID: 15849 (zabbix_agentd)
      Tasks: 6 (limit: 4575)
     Memory: 6.3M
        CPU: 277ms
     CGroup: /system.slice/zabbix-agent.service
...

Step 8 – How To Access Zabbix 6.4 Dashboard?

Now that the Zabbix server and agent are configured, you can access the Zabbix web interface. Open your web browser and navigate to the following URL, replacing <your-server-ip> with the actual IP address of your Ubuntu 22.04 server:

http://<your-server-ip>/zabbix

You will be greeted with the Zabbix welcome page. Select your preferred language and click "Next step."

Follow the on-screen instructions to complete the web-based setup wizard. You’ll need to provide the database connection details (username, password, database name) that you configured earlier. The default username is Admin and the default password is zabbix.

Once the setup is complete, you’ll be redirected to the Zabbix dashboard. Congratulations! You have successfully completed the Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server.

Conclusion

This tutorial provided a detailed Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server, covering installation, configuration, and access to the Zabbix dashboard through the web interface. You should now be able to begin monitoring your systems and applications with Zabbix.

Here are some other articles you may find helpful:

Check Connected WiFi Password on Ubuntu Linux

Install and Run XFCE Desktop on Ubuntu 22.04

Alternative Solutions for Zabbix Installation

While the above guide details a standard installation using a LAMP stack, there are alternative approaches to deploying Zabbix 6.4 on Ubuntu 22.04. Here are two different methods:

1. Using Docker Compose:

Docker Compose allows you to define and manage multi-container Docker applications. This simplifies the Zabbix installation process by containerizing the Zabbix server, database, and web frontend.

  • Explanation: Docker Compose uses a docker-compose.yml file to define the services (containers) required for your application. You can define separate containers for the Zabbix server, a MariaDB database, and the Zabbix frontend (typically based on Apache or Nginx). Docker handles the dependencies and networking between these containers, making deployment easier.
  • Benefits:
    • Simplified installation and configuration.
    • Isolation of Zabbix components from the host system.
    • Easy scaling and management of Zabbix instances.
    • Reproducible deployments across different environments.
  • Code Example (docker-compose.yml):
version: "3.8"
services:
  db:
    image: mariadb:10.6
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_root_password
      MYSQL_USER: zabbixuser
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: zabbixdb
    volumes:
      - db_data:/var/lib/mysql

  zabbix-server:
    image: zabbix/zabbix-server-mysql:latest
    ports:
      - "10051:10051"
    restart: always
    depends_on:
      - db
    environment:
      DB_SERVER_HOST: db
      MYSQL_USER: zabbixuser
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: zabbixdb
      ZBX_SERVERNAME: Zabbix Server

  zabbix-web-apache:
    image: zabbix/zabbix-web-apache-mysql:latest
    ports:
      - "8080:80"
    restart: always
    depends_on:
      - zabbix-server
    environment:
      PHP_TZ: Europe/Berlin  # Change to your timezone
      ZBX_SERVER_HOST: zabbix-server
      MYSQL_USER: zabbixuser
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: zabbixdb
    volumes:
      - ./apache2.conf:/etc/apache2/conf-enabled/zabbix.conf
volumes:
  db_data:

To use this, save the above content in a file called docker-compose.yml in a directory on your server. Create an apache2.conf file in the same directory with the following contents:

<VirtualHost *:80>

    ServerName localhost
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Then run docker-compose up -d from the directory containing the docker-compose.yml file. After the containers are running, you can access Zabbix web interface at http://<your_server_ip>:8080.

2. Using a Pre-Built Virtual Appliance:

Zabbix provides pre-built virtual appliances (VM images) that contain a fully configured Zabbix server, database, and web frontend. These appliances are available for various virtualization platforms like VMware, VirtualBox, and Hyper-V.

  • Explanation: A virtual appliance is a pre-packaged virtual machine image that includes the operating system, Zabbix software, and all necessary dependencies. This eliminates the need for manual installation and configuration, significantly reducing deployment time.
  • Benefits:
    • Fast and easy deployment.
    • Reduced configuration effort.
    • Consistent and reliable Zabbix environment.
    • Suitable for testing and production deployments.
  • Process:
    1. Download the appropriate virtual appliance image from the Zabbix website (https://www.zabbix.com/download_appliance).
    2. Import the image into your virtualization platform (e.g., VMware Workstation, VirtualBox).
    3. Start the virtual machine.
    4. Configure the network settings (IP address, gateway, DNS) within the virtual machine.
    5. Access the Zabbix web interface using the provided IP address.
    6. Change the default password immediately for security reasons.

These alternative methods offer different approaches to deploying Zabbix 6.4 on Ubuntu 22.04, catering to various preferences and technical skill levels. Docker Compose provides a flexible and containerized deployment, while virtual appliances offer the simplest and fastest way to get Zabbix up and running. Choose the method that best suits your needs and environment. The Zabbix 6.4 Installation Guide on Ubuntu 22.04 Server detailed above focuses on the more traditional LAMP stack installation for those who prefer a hands-on approach.