1. Home
  2. Linux
  3. How to install zabbix on ubuntu server

How to install Zabbix on Ubuntu Server

Zabbix is a powerful network monitoring tool for Linux. With it, you can easily keep track of your network devices, applications, etc. In this guide, we’ll show you how you can install Zabbix on Ubuntu Server.

Before we begin

To install Zabbix on Ubuntu Server, you must first update your system. Having the latest packages on Ubuntu ensures everything will run smoothly. To update your Ubuntu system, open up a terminal. Then, use the apt update command to check for software updates.

sudo apt update

After checking for updates on your Ubuntu system, you can install the software using the apt upgrade command. Please note, running the apt upgrade command can take some time, especially if you haven’t upgraded in a while.

sudo apt upgrade

Once your Ubuntu system is up to date, reboot. Chances are, you’ve installed a newer version of the Ubuntu kernel and that requires a restart.

sudo reboot

You’ll be ready to start installing Zabbix when you log back in.

Installing dependencies for Zabbix

Zabbix uses Apache, MySQL, PHP, and other packages. To use it on your Ubuntu system, you’ll need to install all of these dependencies. Using the apt install command below, install everything Zabbix needs to run.

wget https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-2+ubuntu22.04_all.deb
sudo apt install apache2 mysql-server php php-mysql php-mbstring php-gd php-xml libapache2-mod-php zabbix-server-mysql zabbix-frontend-php zabbix-agent

Upon running the command above, Ubuntu will ask you to press Y to confirm you wish to install the packages. Do so. When installed, all dependencies will be installed.

Configuring MySQL/PHP

The Zabbix app requires a MySQL database. To configure this database, start by entering the mysql_secure_installation command. This command will prompt you to set up a MySQL root password for the root user, etc.

sudo mysql_secure_installation

After setting up the root password for SQL on your Ubuntu system, it is time to log into MySQL with the new password. You can log in using the following command.

sudo mysql -u root -p

Once logged in, use the following CREATE DATABASE command.

CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;

Now that the “zabbixdb” database exists in MySQL on your Ubuntu system, you’ll need to create a user for the database using the CREATE USER command. Please change “mypassword” with your preferred Zabbix user passsword.

CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'mypassword';

You must now grant the zabbixuser account all privileges in the “zabbixdb” database. You can do this with the GRANT ALL command in MySQL.

GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixuser'@'localhost';

Exit SQL with the commands below.

FLUSH PRIVILEGES;

exit

You must now import the Zabbix database schema. Enter the commands below.

sudo gunzip /usr/share/zabbix-sql-scripts/mysql/server.sql.gz
sudo mysql -u root -p zabbixdb < /usr/share/zabbix-sql-scripts/mysql/server.sql

After exiting SQL, enter the following commands to update the Zabbix PHP configuration. Note, change “mypassword” to your Zabbix database password. However, keep the “1”.

sudo sed -i 's/^\(DBHost\s*=\s*\).*$/\1localhost/' /etc/zabbix/zabbix_server.conf
sudo sed -i 's/^\(DBName\s*=\s*\).*$/\1zabbixdb/' /etc/zabbix/zabbix_server.conf
sudo sed -i 's/^\(DBUser\s*=\s*\).*$/\1zabbixuser/' /etc/zabbix/zabbix_server.conf
sudo sed -i '/^# DBPassword=/a DBPassword=mypassword' /etc/zabbix/zabbix_server.conf

You now need to change a few PHP configurations so that they meet Zabbix’s requirements. Enter the following commands. Note: the fourth command must be customized to match your timezone. Replace “America” and “Detroit” with your time zone. You can find your timezone with timedatectl list-timezones.

sudo sed -i 's/^post_max_size = .*/post_max_size = 16M/' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/^max_execution_time = .*/max_execution_time = 300/' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/^max_input_time = .*/max_input_time = 300/' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/^;date.timezone =$/date.timezone = America\/Detroit/' /etc/php/8.1/apache2/php.ini

can now enable Zabbix in the Apache2 web server with the following command.

sudo ln -s /etc/apache2/conf-available/zabbix-frontend-php.conf /etc/apache2/conf-enabled/

Setting up Zabbix

Launch Zabbix in your web browser of choice via the following URL:

http://your-ubuntu-server/zabbix

After accessing the URL, Zabbix will prompt you to go through the setup process. Click “Next” to confirm your system is ready to use Zabbix on the “Check of pre-requisites” page.

Once you’ve checked your system for Zabbix on “Check of pre-requisites,” click next to go to the “Configure DB connection” page. From here, enter the following information.

  • Database host = localhost
  • Database name = zabbixdb
  • User = zabbixuser
  • Password = password set in MySQL for “zabbixuser”.

When you’ve filled everything out, click the “Next” button to move to the next page. On the next page, you’ll need to name your Zabbix server, set your time zone and default theme. When done, click “Next step.”

On the final page, you’ll see a congratulations message letting you know you’ve successfully installed Zabbix. From here, you can log into your Zabbix UI with the user information below.

  • Username: Admin
  • Password: zabbix