How to Install and Configure Zabbix on CentOS
In this article
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
- Update the system
Runsudo yum update -y(CentOS 7) orsudo dnf update -y(CentOS 8) to ensure all packages are current. - 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(ordnf clean all). - Install Zabbix server, frontend, and agent
Runsudo yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent(ordnfon CentOS 8). This installs the server, web interface, and monitoring agent. - 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 withsudo mysql_secure_installation(set a root password, remove anonymous users, etc.). - 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;
Replaceyour_passwordwith a strong password. - Import the initial schema
Navigate to the schema directory:cd /usr/share/doc/zabbix-server-mysql(orzabbix-server-mysql-5.0*). Import with:zcat create.sql.gz | mysql -uzabbix -p zabbix. Enter the password you set. This creates the tables. - Configure Zabbix server
Edit/etc/zabbix/zabbix_server.conf. Set the database password: findDBPassword=and uncomment it, then add your password. Save and exit. - Configure PHP for the frontend
Edit/etc/zabbix/web/zabbix.conf.php(or/etc/zabbix/web/zabbix.conf.phpon some versions) and set the database connection details:$DB['PASSWORD'] = 'your_password';and adjust host, name, user as needed. - Set timezone in PHP
Edit/etc/php.ini(or/etc/php.d/*.ini) and setdate.timezone = Your/Timezone(e.g.,America/New_York). Restart PHP-FPM if using it. - Start services
Start and enable Zabbix server, agent, and Apache:sudo systemctl start zabbix-server zabbix-agent httpdand enable them withsudo systemctl enable zabbix-server zabbix-agent httpd. - 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. - Access the web frontend
Open a browser and go tohttp://your_server_ip/zabbix. Follow the setup wizard: check prerequisites, enter DB credentials, and finish. - Log in
Default login isAdmin/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_bincollation 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 onandsetsebool -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.phpfile 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.iniand setdate.timezoneto a valid timezone likeUTC. 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/zabbixif 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).