Wednesday, July 26, 2023

CentOS/RHEL: Installing the Zabbix server

To install Zabbix server on Linux platform CentOS/RHEL follow these steps:

1. First, install the latest security updates for your OS
dnf update --security

and reload
reboot

2. Next, connect all the necessary additional Zabbix repositories and PostgreSQL databases
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf repolist
dnf clean all


3. Install the PostgreSQL database
dnf install -y postgresql15-server

4. Initialize the database and set up automatic startup
/usr/pgsql-15/bin/postgresql-15-setup initdb
systemctl enable postgresql-15
systemctl start postgresql-15


5. Create a user "zabbix" and when prompted enter a password for it, create a database "zabbix"
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix


6. Install Nginx web server and PHP modules
dnf install php
dnf install nginx


7. Configure Web Server service startup and firewall
systemctl start php-fpm
systemctl start nginx
systemctl enable php-fpm nginx
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload


8. Test PHP modules by creating "index.php" page
echo '<?php phpinfo(); ?>' > /usr/share/nginx/html/index.php

and checking access to the page through the browser
http://<hostname>/index.php

9. Then install the Zabbix server with the necessary scripts
dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

10. Run the script for the initial configuration of the Zabbix server database
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

11. Edit the configuration file "/etc/zabbix/zabbix_server.conf", specify the password to access the Zabbix database:
DBPassword=password

12. Edit the Zabbix configuration file "/etc/nginx/conf.d/zabbix.conf", uncomment and specify the parameters:
#listen 8080;
#server_name example.com;


13. Set up Zabbix server autoload and run
systemctl start zabbix-server zabbix-agent
systemctl enable zabbix-server zabbix-agent
systemctl restart zabbix-server zabbix-agent php-fpm nginx


14. Set up rules for SELinux:
to view rules run this
getsebool -a | grep zabbix
to set the value do for example
setsebool -P zabbix_can_network=1

15. Verify that it works, open "http://<hostname:8080>/" in a browser and complete the initial configuration. To log in, use the login "Admin" and the password "zabbix".

No comments:

Post a Comment