Compiling and Installing Zabbix Server on CentOS 7

Publish: 2017-11-29 | Modify: 2019-04-24

Zabbix is an enterprise-level open-source solution that provides distributed system monitoring and network monitoring functionality through a web interface. It is ideal for managing multiple servers and monitoring them using Zabbix. Zabbix consists of two parts, the Zabbix server and the optional component Zabbix agent.

To install Zabbix server, you will need PHP + MySQL support (SQLite, PostgreSQL, and other databases can also be used). Since your server already has the OneinStack (Linux + Nginx + MySQL + PHP) environment installed, it is recommended to install Zabbix server using the source code compilation method to avoid affecting the current environment.

  1. Compile Zabbix server & agent
    • Install dependencies: yum -y install gcc gcc-c++ curl-devel mysql-devel curl-devel net-snmp net-snmp-devel
    • Create user & group: groupadd zabbix and useradd -g zabbix zabbix
    • Download source code (latest version can be found on the official website): wget http://soft.xiaoz.org/linux/zabbix-3.4.4.tar.gz
    • Extract source code: tar -zxvf zabbix-3.4.4.tar.gz && cd zabbix-3.4.4
    • Compile and install: ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 and make install

Note: The latest stable version of Zabbix at the time of writing this article is 3.4. You can find the latest source code package on the official website. If you encounter an error during compilation such as "checking for mysql_config... configure: error: MySQL library not found", you can specify the location of mysql_config. For example: --with-mysql=/usr/local/mysql/bin/mysql_config. If you still encounter errors, search and handle them based on the actual error message. After installing Zabbix server on CentOS 7, the configuration file paths are as follows:

  • /usr/local/etc/zabbix_server.conf
  • /usr/local/etc/zabbix_agentd.conf
  1. Import database

    • Create a database (skipped) and import the three database files from the source code package located in zabbix-3.4.4/database/mysql in the following order:
      • schema.sql
      • images.sql
      • data.sql
    • Modify the configuration file /usr/local/etc/zabbix_server.conf and fill in the correct database account, password, and other information. Then start Zabbix server and Zabbix agent by running zabbix_server && zabbix_agentd.
  2. Install web interface

    • The web interface is developed using PHP, so you need to create a new site and copy all the source code from zabbix-3.4.4/frontends/php to your site directory. Access your domain http://domain.com/ and enter the basic information of your Zabbix server to complete the installation. After successful installation, you will see the login page with the username Admin and password zabbix. Remember to change the password after logging in.

Setting Chinese language:

  • By default, the Zabbix interface is in English. You can set it to Chinese in the personal settings for easier management.

Fixing Chinese garbled characters:

  • Open the C:\Windows\Fonts directory on your computer and copy a Chinese language font file, such as simkai.ttf, to the fonts directory of your site. Rename the font file to DejaVuSans.ttf. This will replace the default font used by Zabbix and fix the garbled characters issue.
  1. Automatic startup
    • Register Zabbix as a service, set permissions, and configure it to start automatically on boot. Run the following commands:
      • cd zabbix-3.4.4
      • cp misc/init.d/tru64/zabbix_server /etc/init.d/zabbix_server
      • cp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd
      • chmod 755 /etc/init.d/zabbix_*
    • Edit the files zabbix_server and zabbix_agentd and add the following lines at the beginning:
      • #chkconfig: 35 95 95
      • #description:zabbix Agent server
    • Register as a service and enable auto-start:
      • chkconfig --add zabbix_server
      • chkconfig --add zabbix_agentd
      • chkconfig zabbix_server on
      • chkconfig zabbix_agentd on

The basic installation is now complete. If you need to monitor data from other servers, you can install the Zabbix client using the official RPM package. The client does not require PHP/MySQL support, and it is recommended to install the client using the official RPM package for convenience.

  1. Further reading

  2. Summary

    • Zabbix is a powerful tool for monitoring server data, especially when managing multiple servers. It provides detailed data, supports various actions and notifications, and has an open API for customization and enhancement.

Comments