HostOnNet Blog

Install Zabbix Server on Ubuntu from Source

Looking for Linux Server Admin or WordPress Expert? We can help.

Zabbix is an enterprise-class open source distributed monitoring solution that can be used to monitor and track performance and availability of network servers, devices and other IT resources.

Before installing Zabbix, we should have install and configure LAMP stack on server.

apt-get install apache2 php php-mysql mysql-server mysql-client

To compile and install from source we need to have the build-essential installed.

apt-get update
apt-get install build-essential

Install the required libraries and PHP extensions.

apt-get install libmysqld-dev libxml2-dev snmp libsnmp-dev libcurl4-openssl-dev
apt-get install php-bcmath php-mbstring php-xmlwriter php-xmlreader

Create a new User and Group

groupadd zabbix
useradd -g zabbix zabbix

Download and extract latest source file of zabbix using wget. (zabbix-3.0.3.tar.gz at the time of writing this post.)

mkdir ~/zabbix
cd ~/zabbix/
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
tar -zxvf zabbix-3.0.3.tar.gz
cd ~/zabbix/zabbix-*/
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install

Create a new MySQL DB and User through terminal.

mysql -u root -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> flush privileges;
mysql> exit;

Import the database files.

mysql -u zabbix -p<password> zabbix < database/mysql/schema.sql
mysql -u zabbix -p<password> zabbix < database/mysql/images.sql
mysql -u zabbix -p<password> zabbix < database/mysql/data.sql

Update MySQL password (DBPassword=) in zabbix server config file.

vi /usr/local/etc/zabbix_server.conf

Start Zabbix Server and Agent by running

zabbix_server
zabbix_agentd

Installing Zabbix web interface

Create a subdirectory and copy Zabbix frontend files into it, execute the following commands

mkdir /var/www/html/zabbix
cd frontends/php
cp -a . /var/www/html/zabbix

http://zabbix-server-ip/zabbix/

If everything OK, you should see the following page.

install_1

Zabbix need atleast the following values in your PHP configuration.

post_max_size = 32M
max_execution_time = 600
max_input_time = 600
date.timezone = "UTC"

If they are not set already, you can change it by editing PHP.INI file.

You can continue to next step if all prerequisites OK (in green)

install_2

Enter details of the database we already created and click on next step

install_3

Enter the name of your Zabbix Server in Server details page and click on next step.

install_4

Review the summary and click next

install_5

Download the configuration file

Upload it to

/var/www/html/zabbix/conf/zabbix.conf.php

install_6

Then FINISH the installation.

install_7

Login to Zabbix Dashboard by using the default login details.

login

http://zabbix-server-ip/zabbix/
Username: Admin
Password: zabbix

Set Zabbbix Server to start on boot

To start Zabbix Server and Agent on boot, copy the init.d scripts to the right spot:

cd ~/zabbix/zabbix-*/
cp misc/init.d/debian/zabbix-server /etc/init.d
cp misc/init.d/debian/zabbix-agent /etc/init.d

Set the correct permissions

chmod 755 /etc/init.d/zabbix-server
chmod 755 /etc/init.d/zabbix-agent

Set Zabbix to start when the machine boots:

update-rc.d zabbix-server defaults
update-rc.d zabbix-agent defaults

You may receive the following warning message when running update-rc.d command.

root@Ubuntu-1604 ~/zabbix/zabbix-3.0.3 # update-rc.d zabbix-server defaults
insserv: warning: script 'K01zabbix-agent' missing LSB tags and overrides
insserv: warning: script 'zabbix-server' missing LSB tags and overrides
insserv: warning: script 'zabbix-agent' missing LSB tags and overrides
root@Ubuntu-1604 ~/zabbix/zabbix-3.0.3 # chmod 755 /etc/init.d/zabbix-agent
root@Ubuntu-1604 ~/zabbix/zabbix-3.0.3 #

root@Ubuntu-1604 ~/zabbix/zabbix-3.0.3 # update-rc.d zabbix-agent defaults
insserv: warning: script 'K01zabbix-agent' missing LSB tags and overrides
insserv: warning: script 'K01zabbix-server' missing LSB tags and overrides
insserv: warning: script 'zabbix-agent' missing LSB tags and overrides
insserv: warning: script 'zabbix-server' missing LSB tags and overrides
root@Ubuntu-1604 ~/zabbix/zabbix-3.0.3 #

It just mean that the special new tags have not yet been added to the boot scripts. The script still work fine, but the insserv program wants them.

You can fix that warning by adding the LSB tags to the init scrips

Open /etc/init.d/zabbix-agent in a text editor.

vi /etc/init.d/zabbix-agent

Add the following code below #!/bin/sh

### BEGIN INIT INFO
# Provides:          zabbix-agent
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop Zabbix-agent
# Description:       Start/stop Zabbix-agent
### END INIT INFO

Save and Exit editor.

Open /etc/init.d//etc/init.d/zabbix-server.

vi /etc/init.d/zabbix-server

Add the following code below #!/bin/sh

### BEGIN INIT INFO
# Provides:          Zabbix daemon
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Should-Start: $all
# Should-Stop: $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop Zabbix server daemon
# Description:       Start/stop Zabbix server daemon
### END INIT INFO

Save and Exit.

Run the update-rc.d command once again.

update-rc.d zabbix-server defaults
update-rc.d zabbix-agent defaults

See Server Monitoring

Posted in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.