zabbix deployment and configuration

zabbix deployment and configuration

  1. zabbix web interface is based on php development, so creating lnmp environment to support access to the web interface
yum install nginx php php-devel php-mysql php-fpm mariadb mariadb-server mariadb-devel epel-release -y
  1. Start mariadb Service
systemctl start mariadb
  1. Zabbix create a database, and perform authorization command.
create database zabbix charset=utf8;
grant all to zabbix.* to zabbix@localhost identified by '123456'
flush privileges;
  1. Switch to zabbix source directory, into the database.
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]# pwd
/root/zabbix-3.4.8
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/schema.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/images.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/mysql.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/data.sql
  #schema.sql  表结构
  #images.sql  图片库
  #data.sql    初始脚本库
  #三个表导入次序不能颠倒:schema-->images-->data。
  1. To upload or download source package zabbix centos system, switching to zabbix source directory after decompression.
[root@localhost ~]# tar -zxf zabbix-3.4.8.tar.gz 
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]# 
  1. Before zabbix source precompiled installation, install the necessary dependencies
[root@localhost zabbix-3.4.8]# yum gcc gcc-c++ open openssl-devel zlib zlib-devel pcre pcre-devel net-snmp net-snmp-devel curl curl-devel libevent-devel -y
  1. zabbix source package pre-compiled, the compiler, the installation.
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl 
make && make install

Write here zabbix-web, zabbix-server mounting portion is completed, while zabbix-mariadb also complete the installation and configuration. The following link into zabbix profile

  1. Zabbix.sever.conf modify files, back up before the amendment
[root@localhost ~]# cp /usr/local/zabbix/etc/zabbix.server.conf /usr/local/zabbix/etc/zabbix.server.conf.bak
[root@localhost ~]# cat >/usr/local/zabbix/etc/zabbix.server.conf <<EOF
  LogFile=/tmp/zabbix_server.log
  DBHost=localhost
  DBName=zabbix
  DBUser=zabbix
  DBPassword=123456
EOF
  1. Zabbix before starting the program, first enter the source package to copy the files to the start zabbix centos system startup scripts.
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]# cp -a misc/init.d/tru64/zabbix_* /etc/init.d/
[root@localhost zabbix-3.4.8]# chmod +x /etc/init.d/zabbix_*
  1. Zabbix start the program running.
**运行报错 1**
  [root@localhost ~]# /etc/init.d/zabbix_server start
  Can't find file /usr/local/sbin/zabbix_server.
  Zabbix server NOT started.
#运行zabbix启动程序报错:提示链接zabbix启动二进制错误,修改/etc/init.d/zabbix_server脚本来解决。
[root@localhost ~]# vim /etc/init.d/zabbix_server 
#找到第24行修改为/usr/local/zabbix/sbin/zabbix_server
![](https://img2018.cnblogs.com/blog/1846345/201910/1846345-20191028011411958-575921307.png)


**运行报错 2**
  [root@localhost ~]# /etc/init.d/zabbix_server start
  zabbix_server [32842]: user zabbix does not exist
  zabbix_server [32842]: cannot run as root!
  Zabbix server started.
#错误提示:zabbix用户不存在,开启zabbix失败。解决:添加用户zabbix后,在启动zabbix启动程序就OK。
[root@localhost ~]# useradd zabbix
[root@localhost ~]# /etc/init.d/zabbix_server start
Zabbix server started.
  1. Zabbix copy program source code file to nginx php html system directory
    ``
    [the root @ localhost ~] -a # CP-zabbix 3.4.8 / frontends / php / * / usr / Share / nginx / html /
12. php和nginx整合配置,修改nginx配置文件

location / {
index index.php setup.php;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

13. 重新启动nginx和php服务

[root@localhost nginx]# systemctl restart nginx php-fpm

14. 访问zabbix web页面
![](https://img2018.cnblogs.com/blog/1846345/201910/1846345-20191028011349300-1495063186.png)





## 待续







Guess you like

Origin www.cnblogs.com/linux123/p/11750111.html