Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Install and Configure Zabbix on CentOS

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Zabbix is an open-source monitoring solution that tracks the availability and performance of servers, networks, and applications. This guide walks you through installing Zabbix server on CentOS 7 or 8, configuring the database, and setting up the web frontend. By the end, you'll have a working monitoring platform ready to add hosts.

What You'll Need

  • A CentOS 7 or 8 server with at least 2 GB RAM and 10 GB free disk space.
  • Root or sudo access to the server.
  • A configured hostname and network connection.
  • Firewalld enabled (default on CentOS) or another firewall tool.
  • Access to the internet to download packages.

Step-by-Step

  1. Update the system
    Run sudo yum update -y (CentOS 7) or sudo dnf update -y (CentOS 8) to ensure all packages are current.
  2. Install the Zabbix repository
    For CentOS 7: rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
    For CentOS 8: rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
    Then clean cache: sudo yum clean all (or dnf clean all).
  3. Install Zabbix server, frontend, and agent
    Run sudo yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent (or dnf on CentOS 8). This installs the server, web interface, and monitoring agent.
  4. Install and configure MariaDB
    Install MariaDB: sudo yum install -y mariadb-server. Start and enable it: sudo systemctl start mariadb && sudo systemctl enable mariadb. Secure it with sudo mysql_secure_installation (set a root password, remove anonymous users, etc.).
  5. Create the Zabbix database and user
    Log into MySQL: sudo mysql -uroot -p. Then run:
    CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
    CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'your_password';
    GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    Replace your_password with a strong password.
  6. Import the initial schema
    Navigate to the schema directory: cd /usr/share/doc/zabbix-server-mysql (or zabbix-server-mysql-5.0*). Import with: zcat create.sql.gz | mysql -uzabbix -p zabbix. Enter the password you set. This creates the tables.
  7. Configure Zabbix server
    Edit /etc/zabbix/zabbix_server.conf. Set the database password: find DBPassword= and uncomment it, then add your password. Save and exit.
  8. Configure PHP for the frontend
    Edit /etc/zabbix/web/zabbix.conf.php (or /etc/zabbix/web/zabbix.conf.php on some versions) and set the database connection details: $DB['PASSWORD'] = 'your_password'; and adjust host, name, user as needed.
  9. Set timezone in PHP
    Edit /etc/php.ini (or /etc/php.d/*.ini) and set date.timezone = Your/Timezone (e.g., America/New_York). Restart PHP-FPM if using it.
  10. Start services
    Start and enable Zabbix server, agent, and Apache: sudo systemctl start zabbix-server zabbix-agent httpd and enable them with sudo systemctl enable zabbix-server zabbix-agent httpd.
  11. Configure firewall
    Allow HTTP/HTTPS and Zabbix ports: sudo firewall-cmd --permanent --add-service=http, --add-service=https, --add-port=10051/tcp, --add-port=10050/tcp. Reload: sudo firewall-cmd --reload.
  12. Access the web frontend
    Open a browser and go to http://your_server_ip/zabbix. Follow the setup wizard: check prerequisites, enter DB credentials, and finish.
  13. Log in
    Default login is Admin / zabbix. Change the password immediately.

Common Mistakes

  • Wrong repository version – Using CentOS 7 repo on CentOS 8 causes dependency errors.
  • Database character set – Not using utf8_bin collation can cause issues with case-sensitive hostnames.
  • Forgetting to import schema – The server won't start if tables are missing.
  • PHP timezone not set – The frontend shows an error and won't proceed.
  • Firewall blocking ports – The agent can't connect to the server if port 10051 is closed.

Tips

  • Use a strong database password and store it securely.
  • Set the server hostname to something descriptive before installing.
  • For production, consider using a dedicated database server or PostgreSQL.
  • Enable SELinux booleans if SELinux is enforcing: setsebool -P httpd_can_connect_zabbix on and setsebool -P zabbix_can_network on.
  • Regularly update Zabbix packages to get security fixes.

Troubleshooting

  • Zabbix server fails to start – Check logs in /var/log/zabbix/zabbix_server.log. Common cause: wrong DB password or missing schema. Verify database credentials and re-import schema if needed.
  • Web frontend shows "Unable to connect to database" – Check the zabbix.conf.php file for correct host, name, user, and password. Ensure MySQL is running.
  • Agent cannot connect to server – Test with zabbix_get -s 127.0.0.1 -k agent.ping. Ensure firewall allows port 10050 and agent is configured with correct Server IP.
  • PHP timezone warning – Edit /etc/php.ini and set date.timezone to a valid timezone like UTC. Restart Apache.
  • Permission denied on web directory – Ensure SELinux allows Apache to access Zabbix files. Use chcon -R -t httpd_sys_content_t /usr/share/zabbix if needed.

Frequently Asked Questions

Can I install Zabbix on CentOS 8 Stream?

Yes, but you may need to use the CentOS 8 repository. If you encounter issues, consider using the official Zabbix repository for RHEL 8, which works with Stream.

What is the default admin password?

The default is Admin / zabbix. Change it after first login.

How do I add a host to monitor?

In the frontend, go to Configuration → Hosts → Create host. Enter the hostname, IP, and attach templates. Ensure the Zabbix agent is installed on the target.

Can I use PostgreSQL instead of MySQL?

Yes, Zabbix supports PostgreSQL. Install zabbix-server-pgsql and zabbix-web-pgsql instead, and follow similar steps with PostgreSQL commands.

How do I upgrade Zabbix later?

Update the repository, then run sudo yum upgrade zabbix-server-mysql zabbix-web-mysql zabbix-agent (or dnf). Follow the upgrade instructions in the release notes.

Why is the web interface not loading?

Check Apache is running (systemctl status httpd), firewall allows port 80, and PHP is installed. Also verify the URL path is correct (/zabbix).