Installing Zabbix Server 6.4 on Ubuntu 22.04

Introduction

When I embarked on my personal lab project five years ago, my goal was clear: to make significant progress in understanding and managing my IT infrastructure. Over the years, I’ve made commendable strides, accumulating a wealth of resources both on-premises and in the cloud. My journey has been one of constant learning and adaptation, with a particular focus on securing my setup. I’m proud to say that, through diligent effort, I’ve established a set of security measures that are not only reliable but have been tested and refined over the past five years.

However, as with any technological endeavor, new challenges inevitably arise. Currently, I find myself grappling with two main issues: Observability & Automation. Operating in Egypt presents its own unique set of challenges for my on-premises setup, including scheduled power outages, high operational costs, and the need for fast incident response. These obstacles underscore the importance of being able to monitor my infrastructure efficiently and automate responses to incidents as they occur.

After much consideration, I’ve chosen Zabbix as the cornerstone of my Observability strategy. Zabbix stands out for its ability to provide a centralized view of all resources or hosts within my network, whether they’re located on-premises or in the cloud. Moreover, it offers the added benefit of enabling automation, which is crucial for managing my infrastructure effectively and responding to incidents swiftly.

Inspired by the potential of Zabbix, I embarked on a personal research project to explore its capabilities firsthand. I successfully installed and configured Zabbix as a proof of concept (POC), integrating it with various types of Resources, including routers, VMs, PCs, laptops, and services. The success of this POC has not only bolstered my confidence in Zabbix but also motivated me to share my experiences with others.

I believe that by documenting my journey and the steps involved in setting up Zabbix, I can assist others who are looking for a straightforward way to install and configure this powerful tool. My hope is that this document will serve as a helpful guide for anyone seeking to enhance their infrastructure’s observability and automation capabilities, regardless of their location or the unique challenges they face.

Prerequisites

Before proceeding, ensure your server meets the following requirements:

  • A VM running Ubuntu Server 22.04 (minimized installation).
  • A non-root user with sudo privileges “zabbix“.
  • A basic firewall setup.

Step 1: Addressing a Common Issue

Some users might encounter an error when running sudo apt update after adding new repositories:

E: Method https has died unexpectedly!
E: Sub-process https received signal 4.

This can be resolved by setting the GNUTLS_CPUID_OVERRIDE environment variable before running apt commands:

sudo GNUTLS_CPUID_OVERRIDE=0x1 apt-get update

Step 2: Installing Zabbix

a. Install Zabbix Repository

To initiate your session on Ubuntu, proceed by logging in with the “zabbix” user credentials.

First, add the Zabbix repository to your system:

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
sudo apt-get update

b. Install Zabbix Server, Frontend, and Agent

Install Zabbix server, frontend, agent, and other necessary packages:

sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.1-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

Step 3: Configuring PostgreSQL for Zabbix

Install PostgreSQL

First, update your package index and install PostgreSQL:

sudo apt-get update
sudo apt install postgresql postgresql-contrib

Configure PostgreSQL Roles and Databases

Switch to the postgres user and access the PostgreSQL prompt:

sudo -i -u postgres
psql # To check if SQL is working, the quit by \q

Create a new role and database for Zabbix:

createuser --interactive # create a user with name 'zabbix'
createdb zabbix

Configure the Zabbix Database

Switch to the zabbix user and log into PostgreSQL:

Create the initial Zabbix database structure:

zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

Switch to the ‘zabbix’ user and access the PostgreSQL database. This command elevates your session to perform database operations under the ‘zabbix’ user privileges

sudo -u zabbix psql

Change the ownership of the database and set a password for the zabbix user:

ALTER DATABASE zabbix OWNER TO zabbix;
ALTER USER zabbix WITH PASSWORD 'your_password';

Step 4: Configuring Zabbix Server

Edit Zabbix Server Configuration

Install vim or your preferred text editor and edit the Zabbix server configuration file:

sudo apt install vim
sudo vi /etc/zabbix/zabbix_server.conf

Set the database password in the configuration file:

DBPassword=your_password

Configure Nginx for Zabbix Frontend

Edit the Zabbix Nginx configuration file to set up the server name and listen port:

sudo vi /etc/zabbix/nginx.conf

Uncomment and set the listen and server_name directives:

listen 8080;
server_name your_domain_or_IP;

Step 5: Starting Zabbix Services

Start the Zabbix server, agent, and necessary web server services:

sudo systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
sudo systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm

Accessing Zabbix Web Interface

Open your web browser and navigate to http://your_domain_or_IP:8080 to access the Zabbix web interface. Follow the on-screen instructions to complete the setup.

Troubleshooting Locale Issues

If you encounter locale issues in the Zabbix GUI, generate the missing locale and reconfigure locales:

sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales

Leave a comment