Book Image

Zabbix Cookbook

By : Patrik Uytterhoeven, patrik uytterhoeven
Book Image

Zabbix Cookbook

By: Patrik Uytterhoeven, patrik uytterhoeven

Overview of this book

Table of Contents (18 chapters)
Zabbix Cookbook
About the Author
About the Reviewers

Installing Zabbix from source

We will now show you how to install Zabbix from source. Remember that for production, it's always better to install from the Zabbix repository or another repository such as Extra Packages for Enterprise Linux (EPEL). First of all, it will make your life easier when you want to upgrade but also when you want to remove some software. Maintainers of Zabbix packages in repositories such as EPEL are always in contact with Zabbix developers and improving the packages. If you compile it by yourself, chances are that you will miss something and will have to do it over later when your setup is already in production.

So why compile, you would think. Well if you can't wait for the latest and greatest new features then it can be a good thing to compile Zabbix in a test environment and try it out. Also, if you or some customer is in high need of one of the new features, it can be an option but then you really have to know what you are doing. Performance can also be a consideration.


If you consider compiling from source, take a checklist with you that lists all options that you need.

Getting ready

To get started with our compilation, we need of course, an operating system and the Zabbix source code. In this case, I will show you how to compile on Red Hat or CentOS 6.x.

For our setup we will need a local working MySQL server with a working Zabbix database and a web server properly configured.


You can also look in the Zabbix online manual under Installation | Installation from sources.

How to do it...

  1. First we download the Zabbix source code which can be obtained from the Zabbix website. When going to download, click on download again; Zabbix stable source is the first on top. Save the file in the /usr/src folder.

  2. Next thing of course, is the extraction of the tar.gz file we have downloaded. This can be done with tar. For example:

    # tar -zxvf zabbix-2.4.x.tar.gz
  3. We now have a folder that contains the Zabbix source code. For example: the /usr/src/zabbix-2.4.x folder.

  4. We need to install Apache, MySQL, PHP, and some other libraries for our server. This can be done with:

    # yum install httpd php php-mysql php-bcmath php-mbstring php- gd php-xml mysql mysql-server -y


    Zabbix supports the following versions: MySQL 5.03 or higher, PostgreSQL 8.1 or higher, Apache 1.3.12 or higher, PHP 5.3 or higher. A full list can be found here:

  5. We also need a user and a group for the Zabbix server to run as since we don't want to run our server as root. So we will create a group and a user Zabbix first:

    # groupadd zabbix
    # useradd -g zabbix zabbix
  6. To be able to start the compilation process, we need to install some extra packages on our system before we can begin, of course:

    # yum install gcc mysql-devel libxml2-devel net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel libssh2-devel iksemel-devel openldap-devel
  7. For some packages you probably have to add the EPEL repository to your setup.

  8. To get a list of all options supported when compiling we have to run next command in the extracted folder:

    # ./configure --help
  9. To compile the sources for a Zabbix server, you could run something like the following line. Options depend on your installation:

    # ./configure --enable-server --enable-agent --with-mysql -- enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 -- with-openipmi --with-unixodbc --with-ssh2 --with-ldap --with- jabber
  10. If finished correctly, you will get a message telling you to run 'make install' now. If you get an error, you probably have to install a missing development library. The last line will tell you what is missing:

    # make install
  11. The compiler will be running for sometime depending on the speed of your system; just let it run till it stops. It will stop after sometime and when there are no errors at the end, your Zabbix server will be compiled.

  12. You need to configure database connection settings, and so on. just like we did with the installation from the Zabbix server from package. The standard location of the configuration files and the Zabbix server can be found under:

    # /usr/local/etc/ → Zabbix configuration files
    # /usr/local/sbin/ → Zabbix server


    If you want to change the location of the Zabbix server installation you could make use of the –prefix=/PATH option when compiling.

    If you have issues don't forget to disable SELinux or better still, put proper SELinux permissions.

    The -j option can be used to speed up compiling when running make on a multicore computer such as make -j 4.

  13. As you probably have noticed, there are no init scripts when you compile from source. This is something you will have to create by yourself. Or you could use the ones provided by Zabbix. Those can be found under the /usr/src/zabbix-2,4,x/misc/init.d file.

  14. Now we also need to install the Zabbix frontend. The most easiest way is to copy the files into a sub directory of the HTML root:

    # mkdir /var/www/html/zabbix
    # cd /usr/src/zabbix-2.4.x/frontends/php
    # cp -a . /var/www/html/zabbix
    # chown -R –no-dereference apache:apache /var/www/html/zabbix
  15. Best is to create a zabbix.conf file for Apache in the /etc/httpd/conf.d/ folder:

    <Directory "/var/www/html/zabbix">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value date.timezone Europe/Brussels

How it works...

The downloaded source code from Zabbix will be extracted first in a folder. To be able to run the Zabbix server as a standard user and not as root, we need to create a group and a user. In this case, we added a group zabbix and created a user zabbix and linked the user to the same group.

We then downloaded the development libraries and our gcc compiler so that we were able to compile the Zabbix server from the source code.

The same thing can be done for the Zabbix agent and the Zabbix proxy, except that only other compiling options are needed.

There's more...

Since Zabbix 2.2, there is the possibility to monitor virtual machines in VMware. For this to work, it is necessary to give the --with-libxml2 option when compiling, else this functionality will not work.

When compiling an agent, we can make use of the same source code we have downloaded for the compilation of the Zabbix server. The only thing we need to do now, is launch.

# ./configure --enable-agent

When compiling fails, chances that you are missing some development libraries for one of the new options you have added are great. If you are not sure what option has caused this, then it can make sense to remove some options and start over. Later if compiling works, you can then add the new options again, one by one, to see where it fails. Zabbix also provides a URL with information on how to install from source: