Zabbix is a popular open-source monitoring solution that allows you to monitor the health and performance of servers, network devices, and other IT infrastructure. In this guide, we will walk you through how to install and configure Zabbix Server and Client on Rocky Linux 9. Hosting your Zabbix server on a WindowsVPS ensures optimal performance and scalability with the dedicated resources of a VPS server.
Step 1: Update Your VPS Server
Before installing Zabbix, ensure your VPS server is up to date. Run the following commands to update your Rocky Linux system:
sudo dnf update -y
Running Zabbix on a WindowsVPS allows you to take advantage of dedicated CPU, memory, and storage resources, ensuring better performance for monitoring large environments.
Step 2: Install Apache, MariaDB, and PHP (LAMP Stack)
Zabbix requires a web server, a database, and PHP to run. Install the LAMP stack (Linux, Apache, MariaDB, PHP) by running the following command:
sudo dnf install httpd mariadb-server mariadb php php-mysqlnd php-fpm php-json -y
Start and enable Apache and MariaDB:
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
Step 3: Secure MariaDB
It is important to secure MariaDB. Run the following command to start the security script:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure the database.
Step 4: Add the Zabbix Repository and Install Zabbix Server
Next, add the Zabbix repository for Rocky Linux 9. Run the following commands to install the Zabbix repository and the Zabbix server package:
sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-1.el9.noarch.rpm
sudo dnf clean all
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y
Step 5: Create a Database for Zabbix
Log in to MariaDB and create a database for Zabbix:
sudo mysql -u root -p
Run the following SQL commands to create the database and user for Zabbix:
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace your_password
with a secure password of your choice.
Step 6: Import the Initial Zabbix Database Schema
To initialize the Zabbix database schema, run the following command (you will be prompted for the password of the zabbix
user):
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix -p zabbix
Step 7: Configure the Zabbix Server
Edit the Zabbix server configuration file to set the database information:
sudo nano /etc/zabbix/zabbix_server.conf
Update the following parameters with your database credentials:
DBName=zabbix
DBUser=zabbix
DBPassword=your_password
Step 8: Configure PHP for Zabbix
Edit the PHP configuration for Zabbix by opening the following file:
sudo nano /etc/php-fpm.d/zabbix.conf
Ensure the following settings are configured correctly:
php_value[date.timezone] = Europe/London
Replace Europe/London
with your own timezone.
Step 9: Start Zabbix Server and Agent
Start the Zabbix server and agent services, and enable them to run on boot:
sudo systemctl restart zabbix-server zabbix-agent httpd php-fpm
sudo systemctl enable zabbix-server zabbix-agent httpd php-fpm
Step 10: Configure Firewall for Zabbix
If you have a firewall enabled, open the necessary ports for Zabbix (port 10051 for the server and port 10050 for the agent):
sudo firewall-cmd --permanent --add-port=10051/tcp
sudo firewall-cmd --permanent --add-port=10050/tcp
sudo firewall-cmd --reload
Step 11: Complete Zabbix Installation via Web Interface
Now, open your web browser and navigate to http://your-server-ip/zabbix
. You will be guided through the installation process. Use the database information you configured earlier.
Once the setup is complete, you can log in to the Zabbix web interface using the default username Admin and password zabbix. It is recommended to change the default password immediately after the first login.
Step 12: Install Zabbix Agent on Client Machines
To monitor other machines (clients), install the Zabbix agent on those machines. For each client, run the following commands:
sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-1.el9.noarch.rpm
sudo dnf clean all
sudo dnf install zabbix-agent -y
Edit the Zabbix agent configuration file to point to your Zabbix server:
sudo nano /etc/zabbix/zabbix_agentd.conf
Update the following parameters:
Server=your-zabbix-server-ip
ServerActive=your-zabbix-server-ip
Hostname=your-client-hostname
Start the Zabbix agent on the client machine:
sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent
Step 13: Optimize Your VPS Server for Zabbix
For optimal performance, hosting Zabbix on a WindowsVPS ensures that your monitoring platform has access to dedicated resources such as CPU, memory, and storage. A VPS server allows for better performance and scalability, especially when monitoring large-scale environments with many clients and devices. As your monitoring needs grow, you can easily scale your VPS resources to ensure Zabbix continues to operate efficiently.
Conclusion
Zabbix is a robust solution for monitoring infrastructure, and by following this guide, you can install and configure both the server and client on Rocky Linux 9. Hosting your Zabbix server on a WindowsVPS ensures your monitoring setup performs optimally and scales with your needs.
For more information about VPS hosting and optimizing your Zabbix setup, visit WindowsVPS today.