To successfully deploy Zabbix, several prerequisite components must be installed:
- A MySQL database server, version 5.7 or later.
- PHP, version 7.2.
- The Zabbix server component.
- The Zabbix web frontend component.
- The Zabbix agent component.
- The Zabbix proxy component (optional).
To add the Zabbix 5.0 repository, you can use either the official Zabbix yum repository or a mirror. For the official repository, run:
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
Alternatively, consider using a local mirror such as the one provided by Tsinghua University.
Install Zabbix Server and Agent
Proceed with installing the core Zabbix server and agent packages:
yum install zabbix-server-mysql zabbix-agent
Enable Zabbix Frontend Repository
Edit the Zabbix repository configuration file, typically located at /etc/yum.repos.d/zabbix.repo, and ensure the zabbix-frontend repository is enabled:
[zabbix-frontend]
...
enabled=1
...
Install Zabbix Web Front end
Before installing the web frontend, it might be necessary to install the CentOS Software Collections (SCL) repository. Then, install the web frontend packages:
yum install centos-release-scl
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
Create Zabbix Database
Ensure your MySQL server (version 5.7+) is installed and running. Execute the following commands on the database host to create the Zabbix database, user, and grant priivleges:
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'your_strong_password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
Import the initial Zabbix database schema and data. You will be prompted for the password set for the 'zabbix' user:
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Configure Zabbix Server Database Connection
Edit the Zabbix server configuration file, /etc/zabbix/zabbix_server.conf, and set the database password:
DBPassword=your_strong_password
Configure Zabbix Frontend PHP and Nginx
Modify the Nginx configuration for Zabbix, typically found at /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf. Uncomment and adjust the listen and server_name directives to match your server's IP address or domain name:
# listen 80;
# server_name your_server_ip_or_domain;
Next, edit the PHP-FPM configuration for Zabbix, located at /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, and set the timezone:
listen.acl_users = apache,nginx
php_value[date.timezone] = Asia/Shanghai
Start and Enable Zabbix Services
Restart the Zabbix server, agent, Nginx, and PHP-FPM services, and configure them to start automatically on boot:
# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
Access the Zabbix web installer by navigating to your server's IP address in a web browser (e.g., http://your_server_ip). Follow the on-screen prompts through the installation steps, including prerequisite checks, database configuration, and Zabbix server details.
Upon completion, you will be redirected to the Zabbix login page (e.g., http://your_server_ip/index.php). Log in using the default credentials: Username Admin and Password zabbix. Note that both username and password are case-sensitive.