How to install and configure Zabbix on CentOS 7
Hi my name is Muneeb Shoukat In this tutorial, we shall provide you a guide on installing and configuring Zabbix on CentOS system.
Before that let’s take a look at the prerequisites.
Prerequisites
- Apache web server
- PHP with required extensions
- MySQL/ MariaDB server
Installing Zabbix on CentOS
Login to Terminal as root and start firing up the commands below.
Step 1 – Disable SELinux
Open SELinux configuration and edit the file:
vim /etc/sysconfig/selinux
You can also use "Vi" and "nono". vi/vim/nano is command-line editor.
Change “SELINUX=enforcing” to “SELINUX=disabled”
Save and exit the file.
After change your file save it and exit the file use :x.
If you use vi/vim then insert ( if you want write and changing in your file ) file use " i " and after changing Enter " Esc " to insert out after do this Enter" : " :x to exit the file.
Then reboot the system.
Run this cmd at your command Terminal
When you Run This command its take few Time.We use this command for Reboot our system/Machine/VM/Ec2/OS
reboot
Step 2 - Update your system
Get the latest updates for your CentOS server
yum update -y
Step 3 – Install and Configure Apache
Apache is Web Server, Apache is responsible for accepting directory (HTTP) requests from Internet users and sending them their desired information in the form of files and Web pages.
Use the following commands:
yum -y install httpd
check service status.
systemctl status httpd.service
If Apache service is not running, start it manually.
systemctl restart httpd.service
Enable httpd service on system boot.
systemctl enable httpd
Step 4 – Configure Needed Repositories
Install epel and remi repos.
yum install php
yum -y install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Disable PHP 5 repositories and enable PHP 7.2 repo.
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php72
php --version
php 5.4 to php 7.2 replace link
Step 5 – Install PHP
yum install php php-pear php-cgi php-common php-mbstring php-snmp php-gd php-pecl-mysql php-xml php-mysql php-gettext php-bcmathModify the PHP time Zone by editing the php.ini file. use vi if do not work vim
vim /etc/php.iniUncomment the following line and add your time zone.
Write your appropriate Time Zone. after change your Time Zone save your file
and exit the file Cntrl X
if. you use vi/vim then insert ( if you want write and changing in your file ) file use " i " and after changing Enter " Esc " to insert out after do this Enter Cntrl X to exit the file .
date.timezone = Asia/KarachiStep 6 – Install MariaDB
yum --enablerepo=remi install mariadb-serverStart the MariaDB service.
systemctl start mariadb.serviceEnable MariaDB on system boot.
systemctl enable mariadbRun the following command to secure MariaDB.
mysql_secure_installationAdd a new root password and continue. Then it will ask a few questions. Type “Y” to agree to that.
Everythings go with "Yes"
Login to DB server and verify.
mysql -u root -pStep 7 – Create a Database for Zabbix
When you Run Above Command you Enter Your MariaDB server .Now the Time Create your Database at your DB server which have you install above.....You can choose any name for the database in place of Zabbixdb . like muneebdb , some things else.DBName: zabbixdb
DBUser: zabbixuser
DBPassword: passwordcreate database zabbixdb character set utf8 collate utf8_bin;When you Run this Commands its show only " Query ok, 1 Row affected " this types show message.Next Run This Commandscreate user 'zabbixuser'@'localhost' identified BY 'password';grant all privileges on zabbixdb.* to zabbixuser@localhost ;When you Run this Commands its show only " Query ok, 0 Row affected " this types show message.
Flush privileges.
flush privileges;Note: your Database is created Now if you want see itRun this command in your MariaDB Server if you want to see your created Databaseesshow databases;Note: Otherwise Run this Command to exit and quit your MariaDB Server. Because we done our work at DB Server AND Return at normal Shell.quit;Step 8 – Install Zabbix and needed dependencies
Adding Zabbix repository. Copy the latest download URL from the official website. Paste it in the below command appropriately.
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpmInstall Zabbix.
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-getStep 9 – Configure Zabbix
Change Time Zone by editing the Zabbix Apache configuration file.
vim /etc/httpd/conf.d/zabbix.confUncomment the following line and add your Time Zone.
php_value date.timezone Asia/KarachiPHP Parameters should look like as follows:
Chang thses all line in file:
php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value max_input_vars 10000 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/KarachiRestart HTTPD service.
systemctl restart httpd.serviceGenerally, Zabbix installation package gives SQL file which includes an initial schema and data for the Zabbix server with MySQL.
Change directory and go the Zabbix directory.
cd used for Change directory. in this command we change current dir and go other dir.
cd /usr/share/doc/zabbix-server-mysql-4.0.4/Import the MySQL dump file.
When you Run This command it take few seconds and get password , when you write your password its not show at shell
password :password
zcat create.sql.gz | mysql -u zabbixdb -p passwordNow modify the Zabbix configuration file with Database details.
vim /etc/zabbix/zabbix_server.confChange the following parameters in file:
DBHost=localhostDBName=zabbixdbDBUser=zabbixuserDBPassword=passwordThen save and exit the file. Restart Zabbix service.
systemctl status zabbix-server.serviceEnable Zabbix on system boot.
systemctl enable zabbix-server.serviceModify firewall rules.
yum install firewaldfirewall-cmd --add-service={http,https} --permanentfirewall-cmd --add-port={10051/tcp,10050/tcp} --permanentfirewall-cmd --reloadNow restart httpd service.
systemctl restart httpdStep 10 – Setup Zabbix
You can access Zabbix using following URL:
http://public ip of your laptop/VM/EC2 /zabbix/Next:Here you Zabbix will check installed PHP, MySQL/MariaDB versions and parameters, etc.
If you see any parameter failing, you have to modify it and refresh the page.
E.g.:- for PHP parameter you have to modify (/etc/php.ini) file. Click Next
Add database details and click Next.Then you will see server details, and you can add any name for “Name”.Click Next. You should see the Database details and server details.Click Next to complete the installation.
hi bro if face error in DB. i need your help in DB server
ReplyDelete