Zabbix server on Debian

1. Installation

apt-get install nginx postgresql php php-cli php-fpm php-pgsql php-bcmath php-mbstring php-gd php-xml zabbix-server-pgsql zabbix-frontend-php

2. Configuration

2.1 Nginx

Edit Nginx configuration file :

vim /etc/nginx/sites-enabled/default

Add the following at the top of the file :

upstream php-handler {
  server unix:/var/run/php/php7.0-fpm.sock;
}

And add the following in the “server {” part :

location /zabbix {
	if ($scheme ~ ^http:){
		rewrite ^(.*)$  https://$host$1 permanent;
	}
	alias                       /usr/share/zabbix/;
	index                       index.php;
	error_page          403 404 502 503 504  /zabbix/index.php;

	location ~ \.php$ {
		if (!-f $request_filename) { return 404; }
		expires                 epoch;
		include                 /etc/nginx/fastcgi_params;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_index           index.php;
		fastcgi_pass            php-handler;
		fastcgi_param SCRIPT_FILENAME $request_filename;
	}

	location ~ \.(jpg|jpeg|gif|png|ico)$ {
		access_log      off;
		expires         33d;
	}
}

2.2 Postgresql

Login as postgres user :

sudo su postgres

And start the postgres client :

psql

Then let’s create a user, a database and set-up the rights :

postgres=# CREATE USER zabbix WITH PASSWORD 'zabbix';
postgres=# CREATE DATABASE zabbix WITH ENCODING='UTF-8' OWNER zabbix;
postgres=# GRANT ALL PRIVILEGES ON DATABASE zabbix to zabbix;
postgres=# \q

Then log out :

exit 

Edit the file to allow our user :

vim /etc/postgresql/9.6/main/pg_hba.conf

Add the following :

local        zabbix    zabbix         md5

Then restart the service :

service postgresql restart

And finally set-up the database :

gunzip --stdout /usr/share/zabbix-server-pgsql/schema.sql.gz | psql -h localhost -U zabbix -d zabbix -W
gunzip --stdout /usr/share/zabbix-server-pgsql/images.sql.gz | psql -h localhost -U zabbix -d zabbix -W 
gunzip --stdout /usr/share/zabbix-server-pgsql/data.sql.gz | psql -h localhost -U zabbix -d zabbix -W

2.3 PHP

Edit the configuration file:

vim /etc/php/7.0/fpm/php.ini

And modify as follow :

max_execution_time = 300
post_max_size = 16M
max_input_time = 300
date.timezone = Europe/Paris

Then reload the configuration:

service php7.0-fpm reload

2.4 Zabbix server

Open the configuration file :

vim /etc/zabbix/zabbix_server.conf

And adjust the following :

DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

Then restart the service :

/etc/init.d/zabbix-server restart

You can connect to http://127.0.0.1/zabbix to follow the installation :

In order to be able to save the configuration, temporary change the right on the file :

chmod 777 /etc/zabbix/zabbix.conf.php

Save the file, and then reestablish the rights :

chmod 644 /etc/zabbix/zabbix.conf.php

You’re done :).

– Login : Admin
– Pass : zabbix

Happy monitoring !

One thought on “Zabbix server on Debian”

Leave a Reply

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