Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
31.10.2024

How to Install Zabbix on Ubuntu and Debian

Installing Zabbix on Ubuntu or Debian systems allows you to leverage powerful monitoring features to track system health, application performance, and network metrics. This guide will walk you through the steps to install and configure Zabbix on these distributions.

1. Update System Packages

Start by updating your system to ensure that all existing packages are up-to-date.

sudo apt update && sudo apt upgrade

2. Install the Required Dependencies

Zabbix relies on certain software components, including a web server, PHP, and a database. For this setup, we’ll use Apache and MySQL.

Install Apache, MySQL, and PHP

sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php

3. Set Up the Database for Zabbix

Zabbix requires a database to store monitoring data. We’ll create a MySQL database and user specifically for Zabbix.

Step 1: Log into MySQL

sudo mysql -u root -p

Step 2: Create the Zabbix Database and User

Execute the following commands to create a database and user with permissions:

CREATE DATABASE zabbixdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER ‘zabbixuser’@’localhost’ IDENTIFIED BY ‘your_password’; GRANT ALL PRIVILEGES ON zabbixdb.* TO ‘zabbixuser’@’localhost’; FLUSH PRIVILEGES; EXIT;

4. Install Zabbix Server, Frontend, and Agent

Add the Zabbix repository, then install the server, frontend, and agent packages.

Step 1: Add the Zabbix Repository

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu$(lsb_release -rs)_all.deb sudo dpkg -i zabbix-release_6.0-1+ubuntu$(lsb_release -rs)_all.deb sudo apt update

Step 2: Install Zabbix Server and Agent

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

5. Import the Initial Schema

The next step is to import the default schema to set up Zabbix’s database structure.

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

Enter the password for the zabbixuser database user when prompted.

6. Configure the Zabbix Server

Update the Zabbix server configuration file to connect it to the MySQL database.

Edit Zabbix Configuration

sudo nano /etc/zabbix/zabbix_server.conf

Update the following parameters with your database details:

DBName=zabbixdb DBUser=zabbixuser DBPassword=your_password

Save and exit the file.

7. Configure PHP for Zabbix Frontend

Edit the PHP configuration file for Apache to meet Zabbix’s requirements.

sudo nano /etc/zabbix/apache.conf

Update the php_value date.timezone line with your time zone, for example:

php_value date.timezone Europe/London

Save and close the file.

8. Start and Enable Zabbix Server and Agent

Start the Zabbix server and agent, and enable them to start at boot.

sudo systemctl restart zabbix-server zabbix-agent apache2 sudo systemctl enable zabbix-server zabbix-agent apache2

9. Access the Zabbix Web Interface

With Zabbix installed and configured, you can now access the web interface.

  1. Open a web browser and navigate to http://your-server-ip/zabbix.
  2. Follow the installation wizard:
    • On the “Welcome” page, click Next.
    • Check for any missing PHP parameters and continue.
    • Enter the database details you configured in zabbix_server.conf.
    • Complete the setup and login using the default credentials:
      • Username: Admin
      • Password: zabbix

For security, change the default admin password after logging in.

10. Adding Hosts and Monitoring

Once logged in, you can start adding hosts (servers, network devices, etc.) and configuring monitoring:

  • Go to Configuration > Hosts and click Create Host to add devices you want to monitor.
  • Apply templates for standard monitoring items like CPU usage, memory usage, and network traffic.
  • Configure triggers to receive alerts based on specific conditions (e.g., high CPU usage).

11. Setting Up Notifications (Optional)

Zabbix allows you to set up email, SMS, and webhook notifications for alerts. To configure this:

  1. Go to Administration > Media types.
  2. Select or add a notification method.
  3. Assign the media type to a user under Administration > Users.

Conclusion

Installing Zabbix on Ubuntu or Debian enables powerful, scalable monitoring for your infrastructure. With this setup, you’ll be able to monitor system health, configure alerts, and visualize data to maintain a stable and optimized environment.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills