【Ubuntu18.04】搭建监控Zabbix4.0

搭建监控Zabbix

环境(nginx/1.18.0,mysql5.7,php7.0)

先删除apache2(用的Nginx)

两个服务一起会端口冲突,改端口也是可以的

apt-get remove apache2

安装Nginx

wget http://nginx.org/keys/nginx_signing.key

sudo apt-key add nginx_signing.key

echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list

echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list

apt-get update

apt-get install nginx

安装php7.0

add-apt-repository ppa:ondrej/php

apt-get install php7.0

安装php7.0插件

apt install -y php7.0-fpm php7.0-curl php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip php7.0-dev php7.0-bcmath php7.0-ldap

报错处理

rm -rf /var/lib/dpkg/lock*

add-apt-repository ppa:ondrej/php

apt-get update

再重新装一次

安装mysql 5.7

apt install mysql-server

安装zabbix

下载

https://www.zabbix.com/download?zabbix=4.0&os_distribution=ubuntu&os_version=18.04_bionic&db=mysql&ws=apache

wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb

dpkg -i zabbix-release_4.0-3+bionic_all.deb

apt update

安装zabbix server,前端和代理

apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

创建数据库、授权

root@zabbix:/etc/nginx/conf.d# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.24-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
 
affiliates. Other names may be trademarks of their respective
 
owners.
 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
 
mysql> create database zabbix character set utf8 collate utf8_bin;
 
Query OK, 1 row affected (0.00 sec)
 
 
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
 
Query OK, 0 rows affected, 1 warning (0.01 sec)
 
mysql> quit

导入数据库表结构

root@zabbix:~# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:

配置zabbix配置文件

vim /etc/zabbix/zabbix_server.conf

DBPassword=密码

复制zabbix文件到前端

cp -r /usr/share/zabbix/ /var/www/

nginx配置文件

vim /etc/nginx/conf.d/zabbix.conf

server {
        listen  80;     ##端口
        server_name localhost;
        root /var/www/zabbix/;
        access_log      /var/log/nginx/zabbix_access.log;
        error_log       /var/log/nginx/zabbix_error.log;
        index index.php;
 
        location ~ \.php$ {
              fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
              fastcgi_index  index.php;
              fastcgi_buffer_size 128k;
              fastcgi_buffers 64 256k;
              fastcgi_param  SCRIPT_FILENAME  /var/www/zabbix$fastcgi_script_name;
              include        fastcgi_params;
          }
}

更改默认的nginx配置文件

vim /etc/nginx/conf.d/default.conf

server {
    listen       8080;           ##端口改成8080
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

启动nginx,php服务

systemctl start nginx

/etc/init.d/php7.0-fpm start

修改nginx的用户

vim/etc/nginx/nginx.conf



user  root;
worker_processes  1;

重启nginx服务

nginx -t
nginx -s reload

 

上面有报错看见什么就修改什么,按照上面的要求改

vim /etc/php/7.0/fpm/php.ini
 
post_max_size = 16M
 
max_execution_time = 300
 
max_input_time = 300
 
date.timezone = Asia/Shanghai


重启服务

/etc/init.d/php7.0-fpm restart

nginx -s reload

默认账号:Admin,密码:zabbix

参考

https://blog.csdn.net/qq_33317586/article/details/83867756

猜你喜欢

转载自blog.csdn.net/lengyer/article/details/114305030