Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Self Host Zabbix: A Beginner’s Complete Guide

How to Self Host Zabbix: A Beginner’s Complete Guide

Zabbix is a powerful open-source monitoring solution that helps you track the health, performance, and availability of your IT infrastructure. Self-hosting Zabbix allows you to maintain full control over your monitoring environment, customize it to your needs, and avoid recurring subscription fees. This guide walks beginners through the entire process of installing and configuring Zabbix on a server, so you can start monitoring your devices, servers, and applications efficiently.

What You’ll Need

  • A server or virtual machine running a supported Linux distribution (e.g., Ubuntu 20.04+, CentOS 7+, Debian 10+)
  • Root or sudo access to the server
  • Basic familiarity with the Linux command line
  • A stable internet connection for downloading packages
  • A modern web browser for accessing the Zabbix frontend
  • Minimum of 2GB RAM and 20GB free disk space (more if monitoring many hosts)
  • Optional: A domain name or static IP for easier access

Step-by-Step

  1. Update your server packages. Run sudo apt update && sudo apt upgrade -y (Ubuntu/Debian) or sudo yum update -y (CentOS) to ensure your system is current.
  2. Install required dependencies. Zabbix requires a web server, database, and PHP. Install these first:
    • For Ubuntu/Debian: sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-bcmath php-mbstring php-gd php-xml php-ldap php-json -y
    • For CentOS: sudo yum install httpd mariadb-server php php-mysqlnd php-bcmath php-mbstring php-gd php-xml php-ldap php-json -y
  3. Start and secure your database server. For MySQL/MariaDB:
    • Enable and start the service: sudo systemctl enable --now mysql or sudo systemctl enable --now mariadb
    • Run sudo mysql_secure_installation and follow prompts to set root password and remove test databases.
  4. Create a database and user for Zabbix. Log into MySQL with sudo mysql -u root -p then run:
    CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
    CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'your_password_here';
    GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
        
  5. Add the official Zabbix repository and install Zabbix server, frontend, and agent.
    • For Ubuntu/Debian, download and install the repo package from Zabbix downloads.
    • For CentOS, similarly add the repo RPM.
    • Then install with:
      • sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent (Ubuntu/Debian)
      • sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent (CentOS)
  6. Import initial schema and data into the database. Run:
    sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
        

    This sets up the required tables and initial data.

  7. Configure the Zabbix server. Edit /etc/zabbix/zabbix_server.conf and set:
    DBPassword=your_password_here
        

    Replace your_password_here with the password you set for the Zabbix database user.

  8. Configure PHP for Zabbix frontend. Edit the PHP configuration file for Zabbix, usually /etc/php/*/apache2/php.ini or /etc/php.ini, and set:
    • date.timezone = Your/Timezone (e.g., date.timezone = America/New_York)
  9. Start and enable Zabbix server and agent services.
    sudo systemctl restart zabbix-server zabbix-agent apache2  # Ubuntu/Debian
    sudo systemctl enable --now zabbix-server zabbix-agent httpd  # CentOS
        
  10. Open necessary firewall ports. Allow HTTP (80) or HTTPS (443) depending on your setup.
    • For UFW: sudo ufw allow 80/tcp
    • For firewalld: sudo firewall-cmd --permanent --add-service=http and sudo firewall-cmd --reload
  11. Access the Zabbix web frontend. Open your browser and navigate to http://your_server_ip_or_domain/zabbix. Follow the web installer steps:
    • Check pre-requisites
    • Enter database details (user: zabbix, password, database: zabbix)
    • Configure server details
    • Complete installation
  12. Log in to Zabbix frontend. Use the default credentials:
    • Username: Admin
    • Password: zabbix

    Change the password immediately after login.

  13. Start adding hosts and configuring monitoring items. Begin with your server or network devices by installing the Zabbix agent or enabling SNMP monitoring.

Common Mistakes

  • Not setting the correct PHP timezone leads to errors or incorrect timestamps in monitoring data.
  • Forgetting to import the initial database schema results in startup failures or missing tables.
  • Using weak or default database passwords compromises security.
  • Not opening firewall ports blocks access to the Zabbix frontend or agent communication.
  • Skipping the mysql_secure_installation step leaves your database vulnerable.
  • Installing mismatched versions of Zabbix server and frontend can cause compatibility issues.

Tips

  • Use the official Zabbix repositories to get stable and up-to-date packages.
  • Backup your Zabbix database regularly, especially before upgrades.
  • Configure HTTPS for secure access to the Zabbix frontend.
  • Start monitoring with a few critical hosts, then expand as you grow comfortable.
  • Use templates in Zabbix to simplify adding common monitoring items across hosts.
  • Keep your server’s OS and Zabbix updated to benefit from security patches.

Troubleshooting

If the Zabbix frontend does not load:

  • Check that Apache or your web server is running: sudo systemctl status apache2 or sudo systemctl status httpd.
  • Verify firewall rules allow HTTP/HTTPS traffic.
  • Look at Apache error logs (/var/log/apache2/error.log or /var/log/httpd/error_log) for clues.

If the Zabbix server fails to start:

  • Review the Zabbix server log file at /var/log/zabbix/zabbix_server.log for errors.
  • Confirm the database connection settings in zabbix_server.conf are correct.
  • Ensure the database server is running and accessible.

If the web installer shows missing PHP modules:

  • Install the missing PHP extensions and restart the web server.
  • Double-check the PHP version matches Zabbix requirements (PHP 7.4+ recommended for recent Zabbix versions).

If monitoring data is not appearing:

  • Check that the Zabbix agent is installed and running on the monitored host.
  • Verify network connectivity and firewall rules between server and agent.
  • Review agent logs for errors (/var/log/zabbix/zabbix_agentd.log).

Frequently Asked Questions

Can I install Zabbix on Windows?
While Zabbix server is primarily designed for Linux, you can install Zabbix agent on Windows machines to monitor them. The server should run on a Linux system.
Is it necessary to use MySQL/MariaDB, or can I use other databases?
Zabbix supports MySQL, MariaDB, PostgreSQL, and SQLite. MySQL/MariaDB is the most commonly used and well-documented choice.
How do I secure the Zabbix frontend?
Use HTTPS by configuring SSL certificates on your web server, enforce strong passwords, and limit access via firewall or VPN for added security.
Can Zabbix monitor cloud services?
Yes, Zabbix can monitor cloud services via APIs, SNMP, or agents installed on cloud instances. Custom templates may be needed.
What hardware resources does Zabbix require?
Minimum requirements are around 2GB RAM and 20GB disk space for small setups. Larger environments need more resources depending on monitored hosts and data retention.
How often does Zabbix collect data?
By default, Zabbix collects data every 60 seconds, but this interval can be customized per item or template.

By following these steps and advice, beginners can successfully self-host Zabbix and start monitoring their infrastructure effectively. With practice, you can expand your setup, customize alerts, and leverage Zabbix’s full capabilities for proactive IT management.

Related

How to Self Host Zabbix: A Beginner’s Complete Guide
Scroll to top