Introduction:
Monitoring the performance and health of your servers and network devices is crucial for ensuring their reliability. Zabbix is a powerful open-source monitoring solution that allows you to track the status of various network services, servers, and hardware. In this guide, we will walk you through the process of installing and setting up Zabbix on a Ubuntu 22.04 server.
Prerequisites:
Before we begin, make sure you have the following:
- A Ubuntu 22.04 server.
- SSH access to your server with sudo privileges.
- A domain name or static IP address for your server.
Step 1: Update and Upgrade:
First, log in to your Ubuntu server using SSH and update the package list and upgrade the installed packages:
sudo apt update
sudo apt upgrade
Step 2: Install LAMP Stack:
Zabbix requires a web server, database server, and PHP. We’ll install the LAMP (Linux, Apache, MySQL, PHP) stack. Install Apache, MySQL, and PHP along with required PHP modules:
sudo apt install apache2 mysql-server mysql-client php php-mysql php-xml php-bcmath php-mbstring php-json php-gd php-ldap
During the MySQL installation, set a strong root password when prompted.
Step 3: Create a MySQL Database:
Next, log in to the MySQL database server as the root user:
sudo mysql -u root -p
Create a new database for Zabbix:
CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;
Create a MySQL user and grant necessary privileges:
CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Install Zabbix Server and Frontend:
Add the Zabbix repository to your package sources:
wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_5.4-1+ubuntu22.04_all.deb
sudo apt update
Install Zabbix Server, Frontend, Agent, and other necessary packages:
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
Step 5: Import Zabbix Database Schema:
Import the initial database schema into the MySQL database:
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbixuser -p zabbixdb
You will be prompted to enter the password for the ‘zabbixuser’ MySQL user.
Step 6: Configure Zabbix Server:
Edit the Zabbix Server configuration file:
sudo nano /etc/zabbix/zabbix_server.conf
Update the following lines with your MySQL database information:
DBHost=localhost
DBName=zabbixdb
DBUser=zabbixuser
DBPassword=your-password
Save and close the file.
Step 7: Configure PHP Settings:
Edit the PHP configuration for the Zabbix frontend:
sudo nano /etc/zabbix/apache.conf
Find the php_value date.timezone
line and set your timezone (e.g., ‘America/New_York’).
Step 8: Start Zabbix Services:
Start and enable the Zabbix server and agent services:
sudo systemctl start zabbix-server zabbix-agent
sudo systemctl enable zabbix-server zabbix-agent
Step 9: Configure Firewall:
If you have UFW firewall enabled, allow HTTP and HTTPS traffic:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
Reload the firewall rules:
sudo ufw reload
Step 10: Access Zabbix Web Interface:
Open a web browser and access your server using its domain name or IP address (http://your-server). You should see the Zabbix setup page.
- Choose your language and click ‘Next.’
- Confirm that all pre-requisites are met and click ‘Next.’
- Enter your MySQL database details:
- Database host: localhost
- Database name: zabbixdb
- User: zabbixuser
- Password: your-password
Click ‘Next.’
- Configure the Zabbix server details and click ‘Next.’
- Review the configuration and click ‘Next.’
- Finally, click ‘Finish’ to complete the setup.
Step 11: Log in to Zabbix:
Log in with the default credentials:
- Username: Admin
- Password: zabbix
You’re now ready to start monitoring your servers and devices with Zabbix on your Ubuntu 22.04 server.
Conclusion:
You have successfully installed and configured Zabbix on your Ubuntu 22.04 server. Zabbix provides a powerful monitoring platform that can help you keep track of the health and performance of your IT infrastructure. You can now start adding hosts, monitoring items, and creating custom alerts to suit your specific needs.