Introduction:
Zabbix is a powerful open-source monitoring solution that enables administrators to monitor the health, performance, and availability of servers, networks, and applications. In this step-by-step guide, we will walk you through the process of installing and configuring Zabbix on Ubuntu 22.04, empowering you to monitor your servers effectively and ensure optimal performance.
Prerequisites:
Before proceeding with the installation, make sure you have the following prerequisites:
- A server running Ubuntu 22.04.
- Administrative access to the server.
- A stable internet connection.
Step 1: Update System Packages
Begin by updating the package repository and upgrading the system packages to their latest versions. Open a terminal or connect to your Ubuntu 22.04 server via SSH and run the following commands:
sudo apt update sudo apt upgrade -y
Step 2: Install Required Packages
Zabbix has certain dependencies that need to be installed. Execute the following command to install the necessary packages:
sudo apt install -y apache2 mysql-server mysql-client php7.4 libapache2-mod-php7.4 php7.4-mysql php7.4-gd php7.4-curl php7.4-xml php7.4-bcmath php7.4-mbstring php7.4-xmlwriter php7.4-ldap
During the installation process, you will be prompted to set a password for the MySQL root user. Choose a strong password and remember it for later use.
Step 3: Create Zabbix Database
Next, we need to create a MySQL database for Zabbix. Follow these steps to create the database and assign necessary privileges:
- Log in to the MySQL shell:
sudo mysql -u root -p
Enter the password for the MySQL root user.
- Create a new database for Zabbix:
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
3. Create a MySQL user and grant privileges to the Zabbix database:
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES;
Replace 'your_password'
with a strong password of your choice.
- Exit the MySQL shell:
EXIT;
Step 4: Download and Extract Zabbix
Now, let’s download and extract the Zabbix source files. Execute the following commands:
wget https://cdn.zabbix.com/zabbix/sources/stable/5.4/zabbix-5.4.4.tar.gz tar -zxvf zabbix-5.4.4.tar.gz
Step 5: Compile and Install Zabbix
In this step, we will compile and install Zabbix with the necessary configuration:
- Change to the Zabbix source directory:
cd zabbix-5.4.4
2. Configure Zabbix with Apache and MySQL support:
./configure --prefix=/opt/zabbix --enable-server --enable-agent --with-mysql --with-openssl --with-net-snmp --with-libcurl --with-libxml2
3. Compile and install Zabbix:
make install
Step 6: Configure Zabbix Server
Now, we need to configure the Zabbix server to connect to the database and set other important settings:
- Create a configuration file for the Zabbix server:
sudo cp /opt/zabbix/conf/zabbix_server.conf.example /opt/zabbix/conf/zabbix_server.conf
2. Open the configuration file using a text editor:
sudo nano /opt/zabbix/conf/zabbix_server.conf
3. Locate the following lines and modify them as necessary:
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=your_password
Replace 'your_password'
with the password you set for the Zabbix MySQL user in Step 3.
- Save and close the file (Ctrl + X, then Y).
Step 7: Configure Zabbix Frontend
Next, we need to configure the Zabbix frontend to enable access via a web browser:
- Copy the Apache configuration file for Zabbix:
sudo cp /opt/zabbix/frontends/php/apache.conf /etc/apache2/conf-available/zabbix.conf
2. Enable the Apache Zabbix configuration:
sudo a2enconf zabbix.conf
3. Restart Apache to apply the changes:
sudo systemctl restart apache2
Step 8: Create Zabbix Database Schema
We now need to import the Zabbix database schema into the MySQL database:
sudo mysql -u zabbix -p zabbix < /opt/zabbix/database/mysql/schema.sql
Enter the password for the Zabbix MySQL user when prompted.
Step 9: Configure Zabbix Frontend
- Open a web browser and enter the IP address or hostname of your Ubuntu 22.04 server, followed by
/zabbix
(e.g.,http://your_server_ip/zabbix
). - On the Zabbix welcome screen, click on “Next Step.”
- Review the pre-installation checks and click on “Next Step.”
- Enter the database details:
- Database Type: MySQL
- Database Host: localhost
- Database Port: 3306
- Database Name: zabbix
- User: zabbix
- Password: Enter the password you set for the Zabbix MySQL user
- Click on “Next Step.”
- Review the Zabbix server details and click on “Next Step.”
- On the pre-installation summary screen, click on “Next Step.”
- Wait for the installation to complete, and then click on “Finish.”
Step 10: Start Zabbix Server and Agent
- Start the Zabbix server and agent services:
sudo systemctl start zabbix-server zabbix-agent
2. Enable the services to start on system boot:
sudo systemctl enable zabbix-server zabbix-agent
Step 11: Accessing Zabbix Web Interface
You can now access the Zabbix web interface and start monitoring your servers:
- Open a web browser and enter the IP address or hostname of your Ubuntu 22.04 server, followed by
/zabbix
(e.g.,http://your_server_ip/zabbix
). - Log in to the Zabbix web interface using the default credentials:
- Username: Admin
- Password: zabbix
- Upon login, you will be prompted to change the default password for the Admin user. Follow the instructions to set a new password.
- Once logged in, you can start configuring hosts, monitoring parameters, and setting up notifications as per your requirements.
Conclusion:
Congratulations! You have successfully installed and configured Zabbix for server monitoring on Ubuntu 22.04. Zabbix offers a comprehensive set of monitoring features, enabling you to track the performance and availability of your servers effectively. Explore the Zabbix documentation to further customize and enhance your monitoring setup to meet your specific needs.