Method steps for installing and deploying ZABBIX 5.0 of nginx


ZABBIX is an enterprise class open source solution based on web interface to provide distributed system monitoring and network monitoring functions.
ZABBIX can monitor various network parameters to ensure the safe operation of the server system; Flexible notification mechanism is provided to enable system administrators to quickly locate / solve various problems.
ZABBIX consists of two parts, ZABBIX server and optional component ZABBIX agent.
ZABBIX server can provide remote server / network status monitoring, data collection and other functions through SNMP, ZABBIX agent, Ping, port monitoring and other methods. It can run on Linux, Solaris, HP-UX, AIX, free BSD, open BSD, OS X and other platforms.

Experimental environment

Before, you may often deploy ZABBIX based on Apache, but you will occasionally encounter some problems. For example, the framework of the company’s system is nginx, and then the ZABBIX built is based on Apache, which will lead to incompatibility. Today, I’ll take you to operate the deployment of ZABBIX 5.0 based on nginx.
Let’s explain the experimental environment framework of Xiaobian:

Operating system: centos7
Web application: nginx
Database: MariaDB

Installation deployment

Server configuration source

rpm -Uvh

Yum repolist # to view the ZABBIX source files
Yum list ZABBIX * # to view which ZABBIX packages exist in the current source

#Directly install ZABBIX server and client
yum -y install zabbix-server-mysql zabbix-agent

#Install a dependency package for the web front-end service
Yum - y install CentOS release SCL # installs the dependent package of SCL, which is mainly used to call the source

After the installation, we need to modify the yum source file downloaded earlier, because in the 5.0 version of ZABBIX source, the web front-end source is disabled by default, and we need to enable it

cd /etc/yum.repo.d/

vim zabbix.repo
#Find [ZABBIX frontend]
Enabled = 0 # change the closing here to 1, that is, it is on

#After modification, you can find more web related sources in the source file by using Yum list ZABBIX for the second time
#Installing web front end services

yum -y install zabbix-web-mysql-scl zabbix-nginx-conf-scl

At this point, all the ZABBIX server applications have been deployed. Now we will start to deploy the database.

Install the configuration database (MariaDB is used here. Interested students can try to install MySQL by compiling or other methods)

yum -y install mariadb-server 

After the database installation is completed, you can start the database first

systemctl start mariadb.service

#After execution, you can use the following command to check whether the database starts normally

netstat -ltunp | grep 3306

After MariaDB is installed, there is no login password by default. We can directly use Mysql to log in to the database

After logging in, you can create a business library first (note that you should pay attention to the setting of character set when creating the database, otherwise there will be problems in subsequent web deployment)

[[email protected] ~] mysql

Mariadb [(none)] >
Mariadb [(none)] >create database zabbix character set utf8 collate utf8_ bin;  # The character set specified when creating the database is utf8
Mariadb [(none)] >
Mariadb [(none)] >show databases;   # Check whether the database is created successfully

#Here, you can exit the database after the ZABBIX database has been successfully created

Then let’s look at what ZABBIX installed when it was installed

rpm -ql zabbix-server-mysql

Here we can see that ZABBIX provides a compressed package for initializing GZ during installation
We export all the SQL statements in the compressed package to facilitate subsequent use

[[email protected] ~] zcat /usr/share/doc/zabbix-server-mysql-5.0.13/create.sql.gz > zabbix.sql
[ [email protected] ~]Ls # can view the exported SQL file
[[email protected] ~] mysql < zabbix.sql
Error 1046 (3d000) at line 1: no database selected # here you can see that an error is reported and there is no database available for viewing

#Let's slightly modify the zabbix.sql file here

[[email protected] ~] vim zabbix.sql
#Add at the top of the file
use zabbix;

[ [email protected] ~]MySQL < zabbix.sql # and then import the data again

After the import is completed, we enter the database again to view the previously imported data table

[[email protected] ~] mysql

Mariadb [(none)] > use zabbix
Mariadb [(none)] > show tables;   

#Because ZABBIX needs to link the database, we need to do one step of user authorization here

Mariadb [(none)] > grant  all on zabbix.* to [email protected] identified by 'zabbix';

#Here, the database is deployed and configured

Configuration of ZABBIX server

[ [email protected]  ~] vim /etc/zabbix/zabbix_ Server.conf #zabbix server configuration file

#After entering, let's look up dbname. There will be a parameter configuration of dbname = ZABBIX. Here, it is ZABBIX by default
#Dbname = ZABBIX # here, because the name of the database we created is ZABBIX, it does not need to be modified. However, if a student creates a database and the database name is not ZABBIX, it needs to be modified here

Dbuser = ZABBIX # connected user

#The original configuration file has no password by default. It needs to be modified here

#Dbsocket = #socket is the same as the default. There is no need to modify it here

Configuration of PHP on the web side

[[email protected] ~] cd /etc/opt/rh/
[[email protected] rh] ls 
rh-nginx116		rh-php72
[ [email protected] RH] CD rh-php72 # here, first modify the PHP configuration file
[[email protected] rh-php72] ls 
opt	pear  pear.conf  php.d   php-fpm.conf  php-fpm.d   php.ini  pki  pm skel  sysconfig  X11  xdg  xinetd.d
[[email protected] rh-php72]  vim php-fpm.d/zabbix.conf

6 listen.acl_ Users = Apache, the authenticated user that nginx # listens to. It is Apache by default. We need to add an nginx

24 ; php_ Value [date. Timezone] = Europe / Riga # the default time zone here is the European time zone, which needs to be modified
24 php_value[date.timezone] = Asia/Shanghai

#Here, PHP needs to be modified in these two areas

Configuration modification of nginx on the web side

[[email protected] rh-php72] cd ..
[[email protected] rh] cd rh-nginx116
[[email protected] rh-nginx116]  ls
nginx  opt  pki  pm  skel   sysconfig  X11  xdg  xinetd.d
[[email protected] rh-nginx116] cd nginx
[[email protected] nginx] cd conf.d
[[email protected] conf.d] ls

[[email protected] conf.d] vim zabbix.conf
server {
#		listen			 80;
#		server_name;
Here, you only need to modify the above two items. Modify them as
		listen			 80;
		server_ name 		  localhost;   # It can be modified to the domain name corresponding to the business

Here, because the listening port configured in the configuration file is 80 and the listening domain name is local, we need to comment these two items in the main configuration file.

[[email protected] conf.d]  cd ..
[[email protected] nginx] vim nginx.conf
server  {
#		listen				80  default_server
#		listen				[::]:80  default_server

#Here, all configurations in the server are commented out to ensure that the two configuration files do not conflict

Here, our ZABBIX server, PHP, nginx and MySQL have been deployed and configured

Then let’s check some basic security policies in our local area

[[email protected] nginx] systemctl status firewalld
[[email protected] nginx] systemctl disable firewalld
[[email protected] nginx] getenforce
Forcing # indicates the on state and needs to be closed
[[email protected] nginx] setenforce 0
[[email protected] nginx] vim /etc/selinux/config
SELinux = disable # change this to off

Now the deployment is almost complete. Let’s start the corresponding service and see the effect

[[email protected] nginx] systemctl start zabbix-server.service    
[[email protected] nginx] systemctl start rh-php72-php-fpm.service 
[[email protected] nginx] systemctl start rh-nginx116-nginx.service
[[email protected] nginx] netstat -lutnp
Where 9000 is the port of PHP
3306 is the MySQL port
80 is the nginx port
10051 is the port of ZABBIX server

#Check whether the above ports exist. If the ports exist, it means that the corresponding application has been started

After the startup is completed, we can view it through the browser

Just enter the IP address corresponding to our server in the browser for access

Here, it is mainly to check whether the part marked by the small series is OK. If it is not OK, it needs to be repaired for a single item.

Here is the instance name, user and password of the database. Just fill in the information when we install the database

This is ZABBIX’s user name

Here are all the parameters that ZABBIX needs to configure on the web page

Here you can see, Congratulations, you have successfully installed the ZABBIX service

ZABBIX’s default user name is admin and password is ZABBIX

In zabbix5.0, there is a configuration that can be modified to display Chinese characters.

Here we can see that the page has been converted into Chinese.

So far, the deployment of ZABBIX 5.0 based on nginx has been completed. For more information about the installation and deployment of nginx ZABBIX 5.0, please search the previous articles of developeppaer or continue to browse the relevant articles below. I hope you will support developeppaer in the future!