How To Install Zabbix on CentOS 7

Install Zabbix on CentOS 7

In this tutorial, we will show you how to install and configuration of Zabbix on your CentOS 7 server. For those of you who didn’t know, Zabbix is an open-source monitoring tool that is ideal for monitoring your cloud servers. Zabbix is very flexible, information can be retrieved using HTTP/SNMP or by installing a Zabbix agent on the machines to monitor, and allows a lot of customization.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation of Zabbix on a CentOS 7 server.

Install Zabbix on CentOS 7

Step 1. First of all, make sure that all packages are up to date.

yum -y update

Step 2. Install LAMP server.

A CentOS 7 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also, install the required PHP modules:

yum install php-mysql php-gd php-ldap php-xml php-xmlrpc php-mbstring php-mcrypt curl zlib

Step 3. Installing Zabbix.

Besides the Zabbix-repository, you will also need the EPEL repository for some dependencies. If you haven’t done so, add that repo too:

yum install epel-release
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

After adding Zabbix yum repository in your system, Now update package lists and install Zabbix using commands:

yum -y install zabbix-server-mysql zabbix-agent zabbix-web-mysql

Step 4. Configure MariaDB Database for Zabbix.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB.

mysql_secure_installation

Next, we will need to log in to the MariaDB console and create a database for Zabbix. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for the Zabbix software:

MariaDB [(none)]> create database zabbix_db;
MariaDB [(none)]> grant all privileges on zabbix_db.* to zabbix_user@localhost identified by <new_password>;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

Now that the database and user are ready, it’s time to create the database schema for Zabbix in the DB which we just added:

cd /usr/share/doc/zabbix-server-mysql-3.0.1
gunzip create.sql.gz
mysql -u root -p zabbix_db < create.sql

Next, edit the Zabbix server configuration file:

nano /etc/zabbix/zabbix_server.conf
...................................
DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=XXXXXXX
...................................

Step 5. Configure Apache webserver.

Created a file for Apache in /etc/httpd/conf.d/zabbix.conf:

nano /etc/httpd/conf.d/zabbix.conf

Edit this file to look similar to this:

Alias /zabbix /usr/share/zabbix
 
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory> 
<Directory "/usr/share/zabbix/conf">
    Require all denied
</Directory> 
<Directory "/usr/share/zabbix/include">
    Require all denied
</Directory>

Edit timezone in /etc/httpd/conf.d/zabbix to read this, or your own time zone:

php_value date.timezone Europe/London

We should adjust php.ini file as per Zabbix recommended settings:

### nano /etc/php.ini
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Europe/London

Save and close the file. Start/Restart Zabbix and httpd services and make them start automatically on every reboot:

systemctl start zabbix-server
systemctl start zabbix-agent
systemctl restart httpd
systemctl restart mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent

Finally, adjust Firewall and SELinux settings:

firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload 
systemctl restart firewalld
setsebool -P httpd_can_connect_zabbix=1

Step 6. Accessing Zabbix.

Zabbix will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com/zabbix or http://server-ip/zabbix and complete the required steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Install Zabbix on CentOS 7

Congratulations! You have successfully installed Zabbix. Thanks for using this tutorial for installing Zabbix Monitoring Tool on your CentOS 7 system. For additional help or useful information, we recommend you to check the official Zabbix website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!