System administrators often use monitoring tools such as Zabbix to keep an eye on servers, virtual machines, devices connected to their network, and more. Zabbix is a great tool that provides a graphical interface to control and manage these services efficiently.

But the installation process of Zabbix on Linux is quite long and confusing. This article will demonstrate how to easily install Zabbix and its prerequisites on a system running Ubuntu or Debian.

Prerequisites for Zabbix

To successfully install Zabbix on your desktop or server, you'll need:

  • A root account
  • MySQL database
  • PHP
  • Apache server

Step 1: Install Apache and PHP

Since Zabbix is written in PHP, you will have to download PHP and Apache server on your machine.

Add the following PPA repository to your system using add-apt-repository:

        sudo add-apt-repository ppa:ondrej/php
    

Launch the terminal and update your system's repository list using APT:

        sudo apt update
    

Upgrade the installed packages to ensure that no outdated packages are present on your computer.

        sudo apt upgrade
    

Next, download the necessary packages related to Apache and PHP:

        sudo apt install apache2 php php-mysql php-ldap php-bcmath php-gd php-xml libapache2-mod-php
    

After downloading the packages, the system will automatically configure the Apache service to start during boot. Check whether the service is currently running on your machine using systemctl:

        systemctl status apache2
    

If the status displays active (running), then everything's fine. However if not, you'll have to manually start the service.

        systemctl start apache2
systemctl stop apache2
systemctl restart apache2

Step 2: Install and Set Up MySQL Database

Issue the below-given command in the terminal to install MySQL.

        sudo apt install mysql-server mysql-client
    

Now, you have to install the database on your Ubuntu machine. To make your work easier, MySQL provides an installation script that automatically installs the database for you.

Launch the terminal and type:

        mysql_secure_installation
    

Type the root user password and press Enter. The script will ask you some questions to configure the database installation such as:

  1. Set root password?
  2. Remove anonymous users?
  3. Disallow root login remotely?
  4. Remove test database and access to it?
  5. Reload privilege tables now?

Type y and press Enter for all the questions.

Now it's time to create a new database for Zabbix. Launch the terminal and enter the following command:

        mysql -u root -p
    

Execute the following database commands to create a new database and grant appropriate privileges to the new user. Make sure to replace password in the second command with a strong password of your choice.

        $ CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;
$ CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';
$ GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbix'@'localhost' WITH GRANT OPTION;
$ FLUSH PRIVILEGES;

Once done, quit the MySQL shell by typing:

        quit;
    

Step 3: Download and Install Zabbix

To install Zabbix on Ubuntu and Debian, download the DEB package from the official Zabbix repository. Use wget to download the package file:

        wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+buster_all.deb
    

Install the downloaded package using APT.

        sudo apt ./zabbix-release_5.0-1+buster_all.deb
    

Next, download the Zabbix server, agent packages, and the web frontend.

        sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
    

Now, create and load the Zabbix database schema.

        zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u root -p zabbix
    

Step 4: Configure the Zabbix Server

Although you have installed Zabbix on your system, it is not configured to use the database you created before.

Open the Zabbix configuration file located at /etc/zabbix using your favorite Linux text editor.

        nano /etc/zabbix/zabbix_server.conf
    

Now, locate the following lines in the configuration file and change the hostname, username, and password.

        DBHost=localhost
DBName=zabbixdb
DBUser=zabbix
DBPassword=password

Make sure to replace password with a strong password of your choice.

Related: How to Create a Strong Password That You'll Not Forget

Step 5: Configure the Apache Server

Before moving forward, you need to make some changes to the Zabbix Apache configuration file.

To do that, reload the Apache server using systemctl first.

        systemctl reload apache2
    

Open the configuration file using nano or any other text editor.

        nano /etc/zabbix/apache.conf
    

Find the line php_value date.timezone <time_zone> and replace <time_zone> with the time zone corresponding to your geographical location.

Step 6: Finishing Configuration

Now that you have finished tweaking the files, it is time to start the services and set up Zabbix graphically.

Restart the Apache service using systemctl.

        systemctl restart apache2
    

Start the Zabbix server and agent by typing the following command:

        systemctl start zabbix-server zabbix-agent
    

Enable the Zabbix services from the command line.

        systemctl enable zabbix-server zabbix-agent
    

Verify if the Zabbix server is running on your system using the systemctl status command.

        systemctl status zabbix-server
    

Proceed if the status displays active in green font.

Step 7: Tweaking the Firewall With UFW

To ensure that Zabbix works properly on your system, you'll have to open ports 80 and 443 on your network. On Linux, UFW is a great utility that will help you in configuring firewalls and managing ports.

Open ports 80 and 443 by typing the following command:

        ufw allow 80/tcp
ufw allow 443/tcp

Reload your firewall to save the changes.

        ufw reload
    

Step 8: Configure Zabbix Frontend

Launch any web browser on your Linux system and head over to the following address:

        http://localhost/zabbix
    

If you've installed Zabbix on a Linux server, replace localhost with the IP address of the server. The browser will display the Zabbix Welcome page. Click on the Next Step button to continue.

Welcome page for zabbix

Now, Zabbix will check the prerequisites required for the application. If you find a missing package, go ahead and install it using the terminal. Once done, click Next Step.

zabbix settings and prerequisites

Enter the database password entered in the configuration file before. Then select Next Step.

configure zabbix database details

The system will ask you for information related to the server. Enter an appropriate server name and proceed by clicking on Next Step.

server information for zabbix

Zabbix will quickly summarize all the configurations and settings that you've done. Review these settings and click on Next Step if everything looks good.

zabbix installation summary

The installation process will now begin. Select Finish once Zabbix has finished installing.

installation complete zabbix

The system will redirect you to the login page. Enter Admin and zabbix as the username and password respectively. You can change the password later by heading over to Administrator > Users.

login page for zabbix

Now You Can Monitor Your Network Easily

Zabbix is a great way to control and monitor devices on your network. It consists of several tools that a user may need to keep an eye on cloud services, virtual machines, servers, and other devices on their network.

You can also set up a portable network monitor using a Raspberry Pi and Nagios Enterprise Monitoring Server (NEMS). Making use of a Raspberry Pi as a network monitoring device is much better than dedicating a complete desktop to the task.