Install Zabbix in Centos7

We all need a monitoring tool to monitor our infrastructure. But to purchasing a monitoring tool will be costly. Today we will learn, how can we configured our own monitoring tool with a most popular open-source tool "Zabbix".

Lets start installing Zabbix in Centos7.

Let Assuming you have a Centos 7 Linux server.

Step 1: Disable SELinux

Open SELinux configuration and edit the file:

1vim /etc/sysconfig/selinux

Change “SELINUX=enforcing” to “SELINUX=disabled” Save and exit the file. Then reboot the system.


Step 2: Update all packages

1yum update -y

Step 3: Install Apache

Use below command to install Apache:

1yum -y install httpd

Check service status:

1systemctl status httpd.service

If Apache service is in stopped state, start the service manually.

1systemctl start httpd.service

Enable Apache service on system boot.

1systemctl enable httpd

Step 4: Install PHP and other dependencies:

  • Before installing PHP packages, we need to enable the EPEL repo. So, Let install epel and remi repos.
1yum -y install epel-release
2yum -y install
  • Disable PHP 5 repositories and enable PHP 7.2 repo.
1yum-config-manager --disable remi-php54
2yum-config-manager --enable remi-php72
  • Now, Start install PHP packages:
1yum install php php-pear php-cgi php-common php-mbstring php-snmp php-gd php-pecl-mysql php-xml php-mysql php-gettext php-bcmath

Step 5: Modify the PHP time Zone by editing the php.ini file.

  • Open the php.ini file:
1vim /etc/php.ini
  • Uncomment the following line and add your time zone.
1date.timezone = Asia/Kolkata

Step 6: Install Database (MariaDB).

  • Install MariaDB :
1yum --enablerepo=remi install mariadb-server
  • Start the MariaDB service:
1systemctl start mariadb.service
  • Enable MariaDB on system boot:
1systemctl enable mariadb
  • Run the following command to secure MariaDB:
  • Add a new root password and continue. Then it will ask a few questions. Type “Y” to agree to that.

  • Login to DB server and verify.

1  mysql -u root -p

Step 7: Create a Database for Zabbix.

  • Enter in database:
1mysql -u root -p
  • Create database:
1Create database ZabbixDatabase;
  • Create a Database user for zabbix and grant privileges:
1create user 'zabbixDBuser'@'localhost' identified BY 'zabbixpassword@123';
2grant all privileges on ZabbixDatabase.* to zabbixDBuser@localhost ;
  • Flush privileges:
1flush privileges;

Step 8: Now Install Zabbix and needed dependencies:

  • Add Zabbix repository. Copy the latest download URL from the official website. Paste it in the below command appropriately.
1rpm -ivh
  • Install Zabbix and its dependencies:
1yum install zabbix-server-mysql  zabbix-web-mysql zabbix-agent zabbix-get

Step 9: Lets configure the Zabbix

  • Change Time Zone by editing the Zabbix Apache configuration file.
1vim /etc/httpd/conf.d/zabbix.conf
  • Uncomment the following line and add your Time-Zone.
1php_value date.timezone Asia/Kolkata
  • Restart apache service:
1Service httpd Restart

Step 10: Upload database schema.

  • Zabbix installation package gives you a SQL file which includes an initial schema and data for the Zabbix server with MySQL.

  • Change directory and go the Zabbix directory.

1cd /usr/share/doc/zabbix-server-mysql-4.0.4/
  • Import the MySQL dump file:
1zcat create.sql.gz | mysql -u zabbixDBuser -p ZabbixDatabase

Step 11: Now modify the Zabbix configuration file:

  • Open Zabbix configuration file:
1vim /etc/zabbix/zabbix_server.conf
  • Modify the following parameters:

Then save and exit the file.

  • Restart Zabbix service.
1service zabbix-server Restart
  • Enable Zabbix on system boot.
1 systemctl enable zabbix-server.service
  • Now restart httpd service.
1service httpd Restart

Step 12: Final Setup Zabbix

  • You can access Zabbix using following URL: http://Server-Host-Name Or IP /zabbix/
  • You should see the welcome page.
  • Click on Next, then zabbix will check installed PHP, MySQL/MariaDB versions and parameters, etc.
  • If you see any parameter failing, you have to modify the parameters, restart the apache service and refresh the page. Note: for PHP parameter you have to modify (/etc/php.ini) file.
  • After this, Click Next to complete the installation.

Now Zabbix has been installed.