How To Install Zabbix on Debian 9

Zabbix is a free open source tool that has been on the market for more than 19 years. It is a state-of-the-art application focused and created for the monitoring, in real time, of millions of metrics that can be taken from thousands of servers, machines Virtual devices or network devices within an organization which makes Zabbix the ideal solution for both small and large companies.

Now we will see how to install Zabbix on Debian 9.

Update Debian 9 and install Apache, MariaDB, and PHP

1. The first step to take will be to update the Debian 9 packages by running the following commands:

sudo apt-get update -y

sudo apt-get upgrade -y

2. Zabbix runs on the Apache web server, is written in PHP and uses MariaDB / MySQL to store the data. To install Zabbix correctly, Apache, MariaDB, and PHP will be necessary. First, we will install Apache, PHP, and other PHP modules by running the following command:

apt-get install apache2 libapache2-mod-php7.0 php7.0 php7.0-xml php7.0-bcmath php7.0-mbstring -y

3. The next step will be to add the MariaDB repository to the system because the latest version of MariaDB isn't available in the default repository of Debian 9. For this we will execute the following lines:

sudo apt-get install software-properties-common -y

sudo apt-key adv --recv-keys --keyserver 0xF1656F24C74CD1D8

sudo add-apt-repository 'deb [arch=amd64] stretch main'

Note: In some cases, an error may occur when running the second line, for its solution we will perform the following lines

sudo apt remove gnupg

sudo apt install --reinstall gnupg2

sudo apt install dirmngr

4. Once we execute the previous lines, we will update the packages again:

sudo apt-get update -y

5. Now we can install MariaDB with the following command:

sudo apt-get install mariadb-server -y

6. During the installation process of MariaDB we will see the next window where we must enter the password of the MariaDB, root user:

7. We enter it, press Enter, and it will be necessary to confirm it:

8. Once again, click OK and this will complete the process of installing MariaDB in Debian 9.
When we have installed MariaDB, by default it is not secure. Therefore, we must execute the following command to ensure it:

sudo mysql_secure_installation

9. There we will see a series of questions which we will answer in the following way:

Enter current password for root (enter for none): Enter

Set root password? [Y/n]: Y

New password:

Re-enter new password:

Remove anonymous users? [Y/n]: Y

Disallow root login remotely? [Y/n]: Y

Remove test database and access to it? [Y/n]: Y

Reload privilege tables now? [Y/n]: Y

10. Once this is done, we will execute the following lines to start the services and enable them in the system:

sudo systemctl start apache2

sudo systemctl enable apache2

sudo systemctl start mysql

sudo systemctl enable mysql

Install Zabbix Server on Debian 9

By default, the Zabbix server is available in the official Debian 9 repository, but may be outdated.

1. We recommend installing the latest version of the official Zabbix repositories which we can download and add the newest version of the Zabbix repository with the following command:


2. Next, we will install the downloaded repository by executing the following:

sudo dpkg -i zabbix-release_3.0-2+stretch_all.deb

3. We will update the repository packages and proceed to install Zabbix server with frontend web and MySQL support:

sudo apt-get update -y

sudo apt-get install zabbix-server-mysql zabbix-frontend-php -y

4. Now it will be necessary to install the Zabbix agent to collect data about the status of the Zabbix server:

sudo apt-get install zabbix-agent -y

5. After this, start the Zabbix agent service by executing the following:

sudo systemctl start zabbix-agent

sudo systemctl enable zabbix-agent

Configure the Zabbix Database in Debian 9

Zabbix makes use of MariaDB or MySQL as a database back-end. Therefore, we must create a MySQL database and a user for the installation of Zabbix.

1. Execute the following command to access MySQL:

mysql -u root -p

2. Now we are going to execute the following lines in their order. Creation of the database:

CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;

3. Create the user with the access password:

CREATE user zabbix identified by 'password';

4. Granting privileges:

GRANT ALL PRIVILEGES on zabbixdb.* to zabbixuser@localhost identified by 'password';

5. Load privileges


6. Exit MySQL:


7. Next, import the initial schema and the data to the newly created database with the following command:

cd /usr/share/doc/zabbix-server-mysql*/

zcat create.sql.gz | mysql -u zabbix -p zabbixdb

Configure Zabbix on Debian 9

1. Zabbix creates its configuration file in the /etc/zabbix/apache.conf path, we must edit this file and update the Time Zone and PHP configuration, as the case may be:

sudo nano /etc/zabbix/apache.conf

2. In the displayed file we will validate the following values:

php_value max_execution_time 300

php_value memory_limit 128M

php_value post_max_size 32M

php_value upload_max_filesize 8M

php_value max_input_time 300

php_value always_populate_raw_post_data -1

php_value date.timezone Europe/Madrid

3. We save the changes using the following key combination: Ctrl + O

4. We exit the editor using: Ctrl + X

5. Now, let's update the details of the database for Zabbix. We did this by editing the file /etc/zabbix/zabbix_server.conf:

sudo nano /etc/zabbix/zabbix_server.conf

6. There we will establish the following values:





7. We save the changes and leave the editor. We will restart all services:

sudo systemctl restart apache2

sudo systemctl restart mysql

sudo systemctl restart zabbix-server


Configure Firewall on Debian 9

The next step to give is to configure the access ports in the Debian 9 Firewall to allow its optimal access.


1. Install the Firewall by running the following line:

sudo apt-get install ufw -y

2. Enable the Firewall executing:

sudo ufw enable

3. Enable the access ports:

sudo ufw allow 10050/tcp

sudo ufw allow 10051/tcp

sudo ufw allow 80/tcp

4. Apply the changes:

sudo ufw reload

Access Zabbix on Debian 9

1. To access Zabbix, we go to a browser and use the following syntax:


2. Click on Next Step, and we will see the verification of Zabbix parameters.

3. Once this is validated, click on Next Step, and we will complete the steps of the created database:

4. In the next window we will leave the default values:

5. We will see a summary of the parameters:

6. Click Finish to exit the assistant:

In this way, we have installed Zabbix, and now we can start the whole process of analyzing metrics in the system.

Similar Posts

Leave a Reply

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