Tutorial

How To Install Zabbix on Ubuntu & Configure it to Monitor Multiple VPS Servers

Published on July 18, 2013
How To Install Zabbix on Ubuntu & Configure it to Monitor Multiple VPS Servers

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

Introduction

Zabbix is a networked server and software monitor. It can be used to keep track of multiple physical or virtual private server instances.

The client-server model that Zabbix employs allows the cloud server to collect rich sets of data that be used to graph historical trends. This can be very useful for monitoring the performance of the websites and applications hosted on your VPS.

For this guide, we will configure two machines. One will be configured as the server, and the other as a client. They both will run Ubuntu 12.04 LTS on 20GB Droplets.

Installing the Zabbix Server

We will begin by installing the Zabbix server on the VPS that we will use as the monitoring station.

Ubuntu has Zabbix in its repositories, but it is outdated. We will use a PPA with more up-to-date packages instead.

Edit apt source list to add the PPA:

sudo nano /etc/apt/sources.list

Add the following items at the end of the file:

# Zabbix Application PPA
deb http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main
deb-src http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main

Save and close the file.

Next, we need to add the PPA's key so that apt-get trusts the source:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C407E17D5F76A32B

We can now install Zabbix. It will pull in the necessary LAMP dependencies as well:

sudo apt-get update
sudo apt-get install zabbix-server-mysql php5-mysql zabbix-frontend-php

During the installation, you will be asked to choose a password for the MySQL root account. Make a selection and confirm your choice.

Configuring the Zabbix Server

Next, we will need to configure the packages we just installed.

First, we will edit the main Zabbix server configuration file. Open the file with root privileges:

sudo nano /etc/zabbix/zabbix_server.conf

Search for the following properties and set them accordingly. Some may already be set correctly, and some you may have to add. Choose a password as well:

DBName=zabbix
DBUser=zabbix
DBPassword=Your.Password.Here

Save and close the file.

MySQL Configuration

Next, we will go into the package directory and unzip the SQL files that will define our database environment:

cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz

We will import the SQL files into our database. However, we first must create the database and do some initial configuration.

Log into MySQL as the root user using the password that you set up during installation:

mysql -u root -p

First, create a user for Zabbix that matches the information we entered in the "/etc/zabbix/zabbix_server.conf" file. Make sure to use the same information:

create user 'zabbix'@'localhost' identified by 'Your.Password.Here';

Next, we will create the Zabbix database:

create database zabbix;

Give control over the new database to the new user we created:

grant all privileges on zabbix.* to 'zabbix'@'localhost';

The following line will implement our new permissions:

flush privileges;

We are now done with the initial MySQL configuration. Exit back to the shell:

exit;

Now that we have our database set up, we can import the files that Zabbix needs to function. Enter the password for the user "zabbix" that you configured when prompted:

mysql -u zabbix -p zabbix < schema.sql

Do the same with the images file:

mysql -u zabbix -p zabbix < images.sql

And finally, import the data file:

mysql -u zabbix -p zabbix < data.sql

PHP Configuration

We need to adjust some values for the php processing of our monitoring data. Open the php configuration file:

sudo nano /etc/php5/apache2/php.ini

Search for and adjust the following entries. If they do not exist, add them:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC

Save and close the file.

Next, we will copy the Zabbix-specific php file into the configuration directory:

sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php

Open the file:

sudo nano /etc/zabbix/zabbix.conf.php

Edit the following values. Use the same info as when you set up the database earlier:

$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Your.Password.Here'

Save and close the file.

Configuring Additional Files

There are a few more files that we need to configure.

First, we'll move the Zabbix apache file from the package directory:

sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf

Ensure that the "alias" mod is enabled within Apache:

sudo a2enmod alias

Restart Apache to use the copied configuration file:

sudo service apache2 restart

Edit the Zabbix init file to ensure that it performs the correct action:

sudo nano /etc/default/zabbix-server

Go to the bottom and adjust the "START" property to read "yes":

START=yes

Save and close the file. We can now start Zabbix:

sudo service zabbix-server start

Installing and Configuring Zabbix Agent

Next, we need to configure the agent software that reports to the Zabbix server. We will install the agent software on our server machine and an additional client machine.

Follow these steps on both machines. Adjust the commands to reflect the correct information.

First, install the agent software:

sudo apt-get update
sudo apt-get install zabbix-agent

Next, we need to update the configuration files:

sudo nano /etc/zabbix/zabbix_agentd.conf

Edit the "Server" property to reflect the IP Address of the Zabbix server. For the agent configuration on the Zabbix server, you can use "127.0.0.1":

Server=Zabbix.Server.IP.Address

Adjust the "Hostname" property to reflect the hostname of the machine being monitored.

Hostname=Hostname_Of_Current_Machine
<p>Save and close the file.</p>

<p>Restart the agent software:</p>
sudo service zabbix-agent restart

Logging In for the First Time

In your web browser, navigate to your Zabbix server's IP address followed by "/zabbix":

Your.Zabbix.IP.Address/zabbix

You will be presented with a login screen. The default credentials are as follows:

Username = admin
Password = zabbix
Zabbix login screen

When you have logged in, click on the "Configuration" button, and then "Hosts" in the top navigation bar.

Zabbix Host configuration

Click on the name of the server (by default, this should be "Zabbix server"). This will open the host configuration page.

Adjust the Hostname to reflect the hostname of your Zabbix server (this should be the same hostname you entered in the agent configuration for the server machine).

At the bottom, change the "Status" property to "Monitored". Click save.

Zabbix server host definition

You will be dopped back to the Hosts configuration page. Re-click on the hostname again.

This time, click on the "Clone" button at the bottom of the page.

We will configure this to reflect the settings of the client machine. Change the hostname and the IP address to reflect the correct information from the client agent file.

Zabbix client definition

In the "groups" section, select "Zabbix servers" and click the right arrow icon to remove that group. Select the "Linux servers" and click the left arrow icon to add that group setting.

Zabbix client group definition

Click "Save" at the bottom.

After a few minutes, you should be able to see both computers by going to "Monitoring" and then clicking on "Latest data".

There should be information for both the server and client machines populating.

Zabbix latest data

If you click on the arrows next to an item, you can see the collected information.

Zabbix item information

If you click "Graph" you will see a graphical representation of the data points that have been collected:

Zabbix graph example

As with all monitoring software, these graphs will become more interesting the longer the server runs.

There are many other options that you can utilize to keep an eye on your VPS. Explore the interface to get comfortable with the powerful monitoring tools.

By Justin Ellingwood

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Justin Ellingwood
Justin Ellingwood
See author profile
Category:
Tutorial

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
49 Comments
Leave a comment...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Very good tutorial, thanks

Best blog I always follow this blog and always I got good knowledge :)

Hi. I am getting a 404 Not Found on the sources added when I run sudo apt-get update. Has there been an update to the location of the sources?

if some one use ubuntu 14.04 and get 404 Not found please type :

sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf sudo a2enconf zabbix.conf sudo service apache2 restart

Please ignore the previous question/comment. I did mis type. If all else fail read it out loud backwards!

Works like charm…fantastic guide!!

What’s wrong with good old SNMP?

Noting SNMP can still be used in zabbix

If you ever Come to Dominican Rep. Dinner at Best Restaurant is on Me !! best tutorial Ever !

I keep getting this error “mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [include/db.inc.php:77]” when I log in to the Zabbix Server. What is the solution for this?

on fresh installations, you might also need to run “apt-get install php5-mysql”

Hi, This is a great tutorial and it has worked very well on a couple of systems. However, I was doing it on a Ubuntu 12.04 on an arm system(minix neo X-7) and the three .gz files did not download. Is there a way to download them? It is in this place: cd /usr/share/zabbix-server-mysql/ sudo gunzip *.gz

there is no file except the .conf file.

Thanks for the useful tutorial.

If like me you decide to use 14.04 and the packages from the standard ubuntu repos (since zabbix in 14.04 is not so outdated) I had to install php5-mysql or else I would get a blank screen when logging into the zabbix frontend.

Is there a good resource that provides walk throughs for configuring Zabbix to monitor multiple types of systems. I’d be interested to see how configuration using SNMP has been set successfully for other users.

Very good tutorial, thanks a bunch!

Hi Justin. Now that there is a new zabbix package released for Ubuntu 14.04, I was wondering if you could update this article with the modified procedure for 14.04. I tried making appropriate changes but I couldn’t make it work. Thanks

I tried running the command “sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf” to move a file, and its saying that the command cant be found. Thoughts? I cant log onto the zabbix server, I think it could be because of this.

@metalliogre: that happens in Ubuntu versions higher than 12.04. This tutorial works like a charm for 12.04. However, for later versions what happens is that /etc/apache2/conf.d/ directory is not created during the process and you get that error. Even if you manually create that directory and copy that file(I actually tried that) it still doesn’t work. Certain file dependencies have changed and it is looking for these in different places–that is what I gather. I spent countless hours trying various methods and I come very close but at the end it doesn’t work. Some, Linux expert has to look at it and come up with a solution.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
May 29, 2014

@somayaji and @metalliogre: On 14.04, Apache has changed how it handles the configuration directory. It now uses conf-available & conf-enabled, just like how it already had sites-available & sites-enabled. So now, you would do:

<pre> sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf sudo a2enconf zabbix.conf </pre>

@Andrew: I don’t know how to thank you. After countless tries, I got it working–thanks to your suggestion. I had installed zabbix many times on 12.04 but wanted to get it working with the latest operating system. Initially I found out that the packages had to be updated. Recently the packages were updated and ever since, I have been trying each time reinstalling Ubuntu 14.04( so that the old install doesn’t come in the way). I could never see the Zabbix screen just until I followed your advice above.

There is a small change if I may write here for others trying like me. After a fresh install of Ubuntu 14.04 and the latest zabbix package (zabbix-release_2.2-1+trusty_all.deb), it doesn’t create the directory you mentioned above(/usr/share/doc/zabbix-frontend-php/examples/)

Instead, the apache.conf is located at /etc/zabbix and it is almost ready to go. One has to just edit the date.timezone value appropriately. So, after that I copied it to /etc/apache2/conf-available/zabbix.conf followed by sudo a2enconf zabbix.conf. A message popped up saying the apache service has to be reloaded. But, really that a2enconf is the critical element that made it work. Million thanks to you and I am sure, a lot of people trying it on 14.04 will find your help invaluable. Thanks

i do exactly step by step like instructions says, still i get message “The webpage cannot be found” if i try to open http://myserver/zabbix

Why?

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
June 4, 2014

@kenno: Are you running Ubuntu 12.04? If not some of the steps might be different. If you’re running Ubuntu 14.04, see my comments above.

i am running 14.04 ubuntu, i read all comments, but still dosent understand what should i do?

Thanks

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
June 4, 2014

@kenno: Did you run these command from my comment above?

<pre> sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf sudo a2enconf zabbix.conf sudo service apache2 restart </pre>

@astarr, still not working, visit return message of visiting localhost/zabbix show the “301 Moved Permanently”.

Hello Astarr, I used 14.04 and install with ur new syntax. But zabbix doesnt start. I get a white site. With: 192.168.1.5 starts the Apache2 Ubuntu Default Page With: 192.168.1.5/zabbix starts a blank site

I install it two times step by step with this instruction. Everytime the same failure.

Any idea?

Internet Explorer send: HTTP 500: Intern Serverfailure in german (Interner Serverfehler)

@nok_blackhawk , I get the same result as yours.

I also get a white screen, nothing in the Apache error log. Using Ubuntu 14.04. Enabling PHP display_errors and setting debug = 3 in Zabbix conf do not work, still white screen. Dont you just hate following painful installation procedures to be faced with this. If had a dollar… :)

As tudor_bura stated, needed to install php5-mysql

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
June 20, 2014

The package <code>zabbix-frontend-php</code> used to depend on <code>php5-mysql</code> and install it automatically. Looks like that’s changed. I’ll update the article to install it as well.

what needs to be done to the firewall to accept incoming active checks? I allowed 10051 and 10050 in iptables but get the error "active check configuration update from [XXX.XXX.XXX.XXX:10051] started to fail (cannot connect to [[XXX.XXX.XXX.XXX]:10051]: [0x0000274C] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

I followed the Tutorial using Ubuntu 12.04, and when I am at the end where I go to “serverip/zabbix” it opens a download file dialog. Any thoughts on why I don’t go to the login screen?

@gt403cyl2 - I just ran into exactly the same problem while installing on Ubuntu 12.04.

"Does your browser ask if you want to download the php file instead of displaying it? If Apache is not actually parsing the php after you restarted it, install libapache2-mod-php5. It is installed when you install the php5 package, but may have been removed inadvertently by packages which need to run a different version of php. "

That was the fix for me. I knew something wasn’t right with the installation when mlocate php.ini didn’t find a file in /etc/php5/apache2.

See more here - https://help.ubuntu.com/community/ApacheMySQLPHPz

I hope this is helpful!

I actually follow your steps but whenever i am trying to access the server from my laptop it is asking the following question " You have chosen to open: which is: application/x-httpd-php from: http://192.168.1.x Please can i know why it is giving me this message??? I had tried everything but it is the same. The server is ubuntu 12.04

The latest version of Zabbix is 2.2.6. This tutorial was published 13 months ago - what version of Zabbix does this tutorial install?

Worked for me… :)

Good! And I’m using 14.04, I change this command “sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf” to “sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-enabled/zabbix.conf” since there is no “conf.d”.

I installed the agent in other server with ubuntu 14.04 but I got errors.

This error disappeared until I specified the port 10050 in ServerActive=127.0.0.1:10050

1963:20140930:061711.666 active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused)

then there is new error after the above

4008:20140930:075906.133 cannot parse list of active checks:

What does the error mean? Given the remaining error I can still see the server and the metrics in the Zabbix web console… I am not sure what is the effect of that error but I think it just work perfectly fine…

Nice tutorial :) Just wanted to point out that the default admin username was ‘Admin’ (with an uppercase A) on my installation (version 2.2.2 from default Debian (Ubuntu) distribution).

Hi

How can i upgrade to version 2.4?

Hi,

Justin, great tutorial! Thanks!

With the Andrew’s addendum info, everything works like a charm on 14.04 LTS.

For the people like me that need other languages, in my case pt_BR, just 2 simple commands: aptitude install language-pack-pt-base service apache2 restart

root@zabbix:~# aptitude install language-pack-pt-base
The following NEW packages will be installed:
  firefox-locale-pt{a} language-pack-pt{a} language-pack-pt-base
0 packages upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,016 kB of archives. After unpacking 15.6 MB will be used.
Do you want to continue? [Y/n/?]
Get: 1 http://mirrors.digitalocean.com/ubuntu/ trusty/main language-pack-pt-base all 1:14.04+20140410 [4,302 kB]
Get: 2 http://mirrors.digitalocean.com/ubuntu/ trusty/main language-pack-pt all 1:14.04+20140410 [1,992 B]
Get: 3 http://mirrors.digitalocean.com/ubuntu/ trusty-updates/main firefox-locale-pt amd64 33.0+build2-0ubuntu0.14.04.1 [712 kB]
Fetched 5,016 kB in 0s (9,415 kB/s)
Selecting previously unselected package language-pack-pt-base.
(Reading database ... 148798 files and directories currently installed.)
Preparing to unpack .../language-pack-pt-base_1%3a14.04+20140410_all.deb ...
Unpacking language-pack-pt-base (1:14.04+20140410) ...
Selecting previously unselected package language-pack-pt.
Preparing to unpack .../language-pack-pt_1%3a14.04+20140410_all.deb ...
Unpacking language-pack-pt (1:14.04+20140410) ...
Selecting previously unselected package firefox-locale-pt.
Preparing to unpack .../firefox-locale-pt_33.0+build2-0ubuntu0.14.04.1_amd64.deb ...
Unpacking firefox-locale-pt (33.0+build2-0ubuntu0.14.04.1) ...
Setting up firefox-locale-pt (33.0+build2-0ubuntu0.14.04.1) ...
Setting up language-pack-pt (1:14.04+20140410) ...
Setting up language-pack-pt-base (1:14.04+20140410) ...
Generating locales...
  pt_BR.UTF-8... done
  pt_PT.UTF-8... done
Generation complete.

root@zabbix:~# service apache2 restart
 * Restarting web server apache2                                                                                                  [ OK ]
root@zabbix:~#

Very useful thanks a lot!

Great article, thanks! I did it in 15 minutes with no problems at all.

Here a nice lab for Zabbix begginers and IT professionals…

http://www.zabbixlab.eti.br

Very nice one. But, I think it’s missing this command “a2enconf zabbix.conf” to make Apache2 recognize the zabbix.conf and work properly in the new Ubuntu versions.

Hi; I have ubuntu 12.04 and I follow this tutorial step by step, when I arrived to the step PHP Configuration and I wanted to make changes on the file /etc/php5/apache2/php.ini I discover that it doesn’t exist and also the directory /etc/php5/apache2 doesn’t exist what should I do ?

Hi; I have ubuntu 12.04 and I follow this tutorial step by step, when I arrived to the step PHP Configuration and I wanted to make changes on the file /etc/php5/apache2/php.ini I discover that it doesn’t exist and also the directory /etc/php5/apache2 doesn’t exist what should I do ?

Hi I have followed this steps to install zabbix on ubuntu 14.04 server in virtual box & I have installed as well as configured zabbix server also checked that apache2,zabbix server services are running, Still I am facing one issue with web interface of zabbix . I am not able to access web interface of zabbix can you please help me in that??

If you’re getting an error like this when trying to pull in schema.sql

ERROR 1071 (42000) at line 142: Specified key was too long; max key length is 767 bytes

sudo vi schema.sql Delete the following lines: 142,179,204,319,414,430,698,705,901,909,1205

Obviously this is a hack but it works! I haven’t noticed any problems or slowdowns without the unique indexes.

Great tutorial!

In my case, under Ubuntu 12.04 x86_64 the following package was still needed:

apt-get install libapache2-mod-php5

With it, the following path and file was created:

/etc/php5/apache2/php.ini

Thanks!

really good one…

Hey, I have some problem I followed your steps. except I am using php7.0.

first time I’ve got ‘404 Not Found’ because alias not update.

So, I ran sudo a2enconf zabbix.conf sudo service apache2 restart

after that I got Zabbix php source code on my browser, not a webpage.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.