How to install Zabbix on CentOS 7
Introduction
Zabbix is an open source monitoring tool for network services, network hardware, servers, and application. Designed to track and monitor the status of your system and servers. Zabbix offers support for many database systems - including MySQL, PostgreSQL, SQLite, and IBM DB2 - to store data. Zabbix backend is written in C, and the frontend is written in PHP.
Step1: Setup LAMP stack
As a prerequisite for the Zabbix we need LAMP stack in our server
lnstall Apache
Zabbix requires a webserver and the most popular webserver in use today is Apache.
Use the following command to install apache on your machine
yum -y install httpd
Next, run the commands below to stop, start and enable Apache service to always start up with the server boots.
systemctl stop httpd.service
systemctl start httpd.service
systemctl enable httpd.service
Install MariaDB
Zabbix also requires a database server… and MariaDB database server is a great place to start. To install it run the commands below.
yum -y install mariadb-server
After installing MariaDB, the commands below can be used to start and enable MariaDB service to always start up when the server boots.
systemctl start mariadb
systemctl enable mariadb
After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.
mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
systemctl restart mariadb
Install PHP 7.2-FPM and Related Modules
PHP 7.2 may not be available on CentOS default repositories… in order to install it, you will have to get it from third-party repositories.
Run the commands below to add the below third party repository to upgrade to PHP 7.2-FPM
yum -y install epel-release
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Run the commands below to install PHP 7.1 and related modules.
yum -y install mod_php72w php72w-cli php72w-common php72w-devel php72w-pear php72w-gd php72w-mbstring php72w-mysql php72w-xml php72w-bcmath
After install PHP, run the commands below to open PHP default file
vi /etc/php.ini
Then make the change the following lines below in the file and save.
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Jakarta
Restart apache
systemctl restart httpd
Step 2: Configure Zabbix Database
Now that you’ve install all the packages that are required, continue below to start configuring the servers. First run the commands below to create Zabbix database.
Run the commands below to logon to the database server. When prompted for a password, type the root password you created above.
mysql -u root -p
Then create a database.
CREATE DATABASE ZABBIX;
Create a database user
CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON ZABBIX.* TO 'zabbixuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES;
EXIT;
Step 3: Install and Configure Zabbix 3.4
Add the Zabbix repository to the CentOS 7 system.
yum -y install http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Now install Zabbix using the yum command below.
yum -y install zabbix-get zabbix-server-mysql zabbix-web-mysql zabbix-agent
Import the Zabbix database sample to our ‘zabbix’ database. Go to the Zabbix documentation directory and extract the Zabbix sql file.
cd /usr/share/doc/zabbix-server-mysql-3.4.15/
gunzip create.sql.gz
Now import the database sample to our ‘zabbix’ database.
mysql -u root -p ZABBIX < create.sql
Configure Zabbix Server
Zabbix-server is the central process of the Zabbix software system. We will configure the Zabbix-server by editing the configuration file.
vi /etc/zabbix/zabbix_server.conf
On the database line configuration, type the configuration as below and change the ‘DBPassword’ value with your own database password.
DBHost=localhost
DBPassword=password
Now start the Zabbix-server service and enable it to launch everytime at system boot.
systemctl start zabbix-server
systemctl enable zabbix-server
Configure Zabbix Agent
Zabbix-agent must be installed on the target monitoring system. The agent will gather all information of the server and reports data to the Zabbix-server.
vi /etc/zabbix/zabbix_agentd.conf
Change following lines with your own info:
Server=yourip
ServerActive=yourip
Hostname=yourinfo
Now start the zabbix-agent and enable it to launch everytime at system boot.
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl status zabbix-agent
Before going any further, we will restart all of our services using the systemctl commands below.
systemctl restart zabbix-server
systemctl restart zabbix-agent
systemctl restart httpd
Then open your browser and browse to the server domain name followed by install. You should see Zabbix setup wizard to complete. Please follow the wizard carefully.
http://yourip/zabbix/
Then follow the on-screen instructions until you’ve successfully installed Zabbix
You will be redirected to the Zabbix welcome message.
Click on Next step
Now, Zabbix will check all system requirements for its installation. Make sure there is no error
Click on Next step
For the database info, type all your database setup.
Click on Next step
Now comes the Zabbix server details configuration. On the ‘Host’ field, type your own server IP address, and change the name with your own domain name or hostname.
Click on Next step
Make sure all of those configurations are correct, then click the next button to install Zabbix.
And when the installation is complete, you will get the page as shown below.
Click the ‘Finish’ button and you will be redirected to the Zabbix login page.
Conclusion
Zabbix is an open source monitoring tool for network services, network hardware, servers, and application. We hope this article helps you to install Zabbix on your CentOS. TheStack is one of the best web hosting providers that offer premium shared web hosting, cheap dedicated server hosting, VPS server, WordPress hosting, server management and monitoring and DevOps support services. Be assured with our services and reach out to our team of experts to know more.