This guide covers the step-by-step installation of Zabbix on Ubuntu, including setting up the Zabbix server, agent, and frontend interface. It also provides a practical use case demonstrating how to monitor server performance metrics like CPU and memory usage in real-time, ensuring optimal server management.
8 min
Edited:13-10-2024
Zabbix is an open-source monitoring tool for enterprise-level IT infrastructure, networks, and services. With robust features for data collection, alerting, and visualization, Zabbix is an essential tool for monitoring servers, networks, and applications. This guide will walk you through the installation process of Zabbix on an Ubuntu system and demonstrate a use case for monitoring system performance.
Begin by updating your Ubuntu system to ensure all packages are up-to-date:
1. sudo apt update && sudo apt upgrade -y
Zabbix requires a web server, database, and PHP to run. Install Apache, MySQL, and PHP by running the following command:
1. sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-bcmath php-mbstring php-gd php-xml php-ldap php-net-socket php-zip -y
After installation, start Apache and MySQL services and enable them to start on boot:
1. sudo systemctl start apache2
2. sudo systemctl start mysql
3. sudo systemctl enable apache2
4. sudo systemctl enable mysql
Login to MySQL to create a database and user for Zabbix:
1. sudo mysql -u root -p
Run the following SQL commands to create a database and user:
1. CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
2. CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'yourpassword';
3. GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbixuser'@'localhost';
4. FLUSH PRIVILEGES;
5. EXIT;
To install Zabbix, add its official repository to your system. Use the following command to download and install the repository for Ubuntu:
1. wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu20.04_all.deb
2. sudo dpkg -i zabbix-release_6.4-1+ubuntu20.04_all.deb
3. sudo apt update
Next, install the Zabbix server, frontend, and agent using the command:
1. sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent -y
Zabbix comes with a pre-configured database schema. To import it, run the following commands:
1. sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbixuser -p zabbix
Edit the Zabbix server configuration file to add the database connection details:
1. sudo nano /etc/zabbix/zabbix_server.conf
Look for the following lines and modify them:
1. DBHost=localhost
2. DBName=zabbix
3. DBUser=zabbixuser
4. DBPassword=yourpassword
Save the file and exit.
Edit the Apache configuration file for Zabbix’s PHP settings:
1. sudo nano /etc/zabbix/apache.conf
Adjust the php_value date.timezone line to match your timezone:
1. php_value date.timezone Europe/London
After editing, save and close the file.
Enable and start the Zabbix server and agent:
1. sudo systemctl restart zabbix-server zabbix-agent apache2
2. sudo systemctl enable zabbix-server zabbix-agent apache2
If you are running a firewall, open the necessary ports for Zabbix:
1. sudo ufw allow 10050/tcp
2. sudo ufw allow 10051/tcp
3. sudo ufw reload
Now that Zabbix is installed, you can complete the setup through the web interface. Open your browser and navigate to http://<server-ip>/zabbix. You will be presented with the Zabbix setup page. Follow these steps:
1 - Check Pre-requisites: Make sure all PHP settings are correct.
2 - Configure DB Connection: Enter the MySQL database details.
3 - Zabbix Server Details: Specify the hostname and port.
4 - Frontend Settings: Define a name for your Zabbix frontend.
5 - Summary: Review the configuration.
After installation, log in to Zabbix using the default credentials:
Username: Admin
Password: zabbix
To monitor other servers or devices, install the Zabbix agent on the target system. Run the following commands on the remote Ubuntu machine:
1. sudo apt update
2. sudo apt install zabbix-agent -y
Edit the agent configuration file to point to the Zabbix server:
1. sudo nano /etc/zabbix/zabbix_agentd.conf
Modify the following parameters:
1. Server=<zabbix-server-ip>
2. ServerActive=<zabbix-server-ip>
3. Hostname=<remote-server-hostname>
Save and exit the file, then restart the Zabbix agent:
1. sudo systemctl restart zabbix-agent
2. sudo systemctl enable zabbix-agent
1 - Login to Zabbix: Navigate to the Zabbix frontend.
2 - Go to Configuration -> Hosts.
3 - Click “Create Host” and add the remote host’s details (hostname, IP, etc.).
4 - Link Templates: Select the appropriate template, such as Template OS Linux by Zabbix agent.
Once the agent is running, Zabbix will start collecting data from the remote host. You can view metrics like CPU usage, memory consumption, and disk space by going to Monitoring -> Latest Data in the frontend.
Zabbix provides powerful monitoring capabilities for system administrators, offering deep insights into server and application performance. With this guide, you've successfully installed Zabbix on Ubuntu, set up monitoring for remote hosts, and can now use Zabbix's robust alerting and reporting features to ensure smooth system operations.
14-10-2024
This article offers a detailed guide on installing and configuring IPTables on an Ubuntu VPS. IPTables is a powerful firewall tool that helps secure your server by controlling inbound and outbound traffic. Learn how to set up rules for traffic filtering, configure basic security policies, and apply custom rules to protect your VPS.
IPtables
security
12 min
This article offers a comprehensive guide on installing and configuring ModSecurity, a powerful web application firewall (WAF), on an Ubuntu VPS. Learn how to secure your server by filtering and monitoring HTTP requests, set up ModSecurity with Nginx or Apache, and apply rules to protect against common web attacks.
Modsecurity
security
10 min
14-10-2024
This article provides a comprehensive guide on installing and configuring PHP-FPM (FastCGI Process Manager) on an Ubuntu VPS. Learn how to optimize PHP performance for your web applications by configuring PHP-FPM with Nginx or Apache, managing pools, and fine-tuning settings for efficient processing of PHP scripts.
PHP-FPM
speed
optimise
12 min