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. I will show you through the step by step installation Zabbix on CentOS 6.
Step 1. First of all make sure that all packages are up to date.
1 | yum-yupdate |
Step 2. Install LAMP server and include some PHP extension.
1 2 3 | yuminstallhttpdhttpd-devel yuminstallmysqlmysql-server yuminstallphpphp-cliphp-commonphp-develphp-pearphp-gdphp-mbstringphp-mysqlphp-xml |
Start service Apache web server and MySQL also enable it to start on boot of the server:
1 2 3 4 | servicehttpdstart servicemysqlstart chkconfighttpdon chkconfigmysqldon |
Step 3. Install Zabbix.
Add the Zabbix repository and install the packages:
1 | rpm-ivhhttp://repo.zabbix.com/zabbix/2.4/rhel/6/i386/zabbix-release-2.4-1.el6.noarch.rpm |
Use following command to install Zabbix using mysql database support packages on your system:
1 | yuminstallzabbix-server-mysqlzabbix-web-mysqlzabbix-agentzabbix-java-gateway |
Step 4. Configure MySQL Database for Zabbix.
By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL.
1 | mysql_secure_installation |
Next we will need to log in to the MySQL console and create a database for Zabbix. Run the following command:
1 | mysql-uroot-p |
This will prompt you for a password, so enter your MySQL root password and hit Enter. Once you are logged in to your database server you need to create a database for the Zabbix software:
1 2 3 4 | mysql>CREATEDATABASEzabbixCHARACTERSETUTF8; mysql>GRANTALLPRIVILEGESonzabbix.*to'zabbix'@'localhost'IDENTIFIEDBY'SECRET_PASSWORD'; mysql>FLUSHPRIVILEGES; mysql>quit |
Import zabbix templates to Zabbix database:
1 2 3 | mysql-uzabbix-pzabbix</usr/share/doc/zabbix-server-mysql-2.2.8/create/schema.sql mysql-uzabbix-pzabbix</usr/share/doc/zabbix-server-mysql-2.2.8/create/images.sql mysql-uzabbix-pzabbix</usr/share/doc/zabbix-server-mysql-2.2.8/create/data.sql |
Step 5. Configure Apache web server.
Created a file for Apache in /etc/httpd/conf.d/zabbix.conf:
1 | nano/etc/httpd/conf.d/zabbix.conf |
Edit this file to look similar to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 | Alias/zabbix/usr/share/zabbix <Directory"/usr/share/zabbix"> OptionsFollowSymLinks AllowOverrideNone Requireallgranted </Directory> <Directory"/usr/share/zabbix/conf"> Requirealldenied </Directory> <Directory"/usr/share/zabbix/include"> Requirealldenied </Directory> |
Edit timezone in /etc/httpd/conf.d/zabbix to read this, or your own time zone:
1 | php_valuedate.timezoneEurope/London |
We should adjust php.ini file as per zabbix recommended settings:
1 2 3 4 5 6 7 | ### 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 |
Restart the Apache and zabbix service for the changes to take effect:
1 2 3 4 5 6 | servicezabbix-serverstart servicezabbix-agentstart servicehttpdrestart servicemysqldrestart chkconfigzabbix-serveron chkconfigzabbix-agenton |
Step 6. Accessing Zabbix.
Zabbix will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com/zabbix or http://server-ip/zabbix and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.
Congratulation’s! You have successfully installed Zabbix. Thanks for using this tutorial for installing Zabbix Monitoring Tool on CentOS 6 system. For additional help or useful information, we recommend you to check the official Zabbix web site.