ubuntu18.04快速安装zabbix4.0

系统:ubuntu18.04

环境:LNMP(nginx1.14,mysql5.7,php7.0)

一、安装nginx

root@david:~# wget http://nginx.org/keys/nginx_signing.key

root@david:~# sudo apt-key add nginx_signing.key

root@david:~# echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list

root@david:~# echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list

root@david:~# apt update

root@david:~# apt install nginx -y

 

二、安装php7.0

root@david:~# add-apt-repository ppa:ondrej/php 
root@david:~# apt -y install php7.0

三、安装php7.0插件

root@david:~# 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

四、安装mysql5.7

直接安装,源已经是5.7版本

root@david:~# apt install mysql-server

五、安装zabbix

先安装源

root@david:~# wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2%2bbionic_all.deb

root@david:~# dpkg -i zabbix-release_4.0-2+bionic_all.deb

root@david:~# apt update

安装zabbix server,前端,代理

root@david:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

六、创建数据库、授权等

root@david:~# mysql -uroot -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

Bye

七、导入数据库表结构

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

 

八、配置zabbix配置文件

root@david:~# vim /etc/zabbix/zabbix_server.conf

root@david:~# grep ^[a-Z] /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

SocketDir=/var/run/zabbix

DBName=zabbix

DBUser=zabbix

DBPassword=123456

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

FpingLocation=/usr/bin/fping

Fping6Location=/usr/bin/fping6

LogSlowQueries=3000

九、配置zabbix前端

root@david:~# cp -r /usr/share/zabbix/ /var/www/

十、卸载这个apache2,因为我用nginx

root@david:~# apt remove apache2 –y

十一、简单写个nginx配置文件

root@david:/etc/nginx/conf.d# vim zabbix.conf
root@david:/etc/nginx/conf.d# cat zabbix.conf 
server {
        listen  80;
        server_name 10.0.0.121;
        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, php(mysql已启动)

root@david:~# systemctl start nginx

root@david:~# /etc/init.d/php7.0-fpm start

[ ok ] Starting php7.0-fpm (via systemctl): php7.0-fpm.service.

 

十三、测试访问

502错误,查看日志显示nginx对/var/run/php/php7.0-fpm.sock没有权限,修改nginx的user并重载

root@david:/etc/nginx/conf.d# vim /etc/nginx/nginx.conf

root@david:/etc/nginx/conf.d# head -3 /etc/nginx/nginx.conf



user  www-data;

worker_processes  1;

root@david:/etc/nginx/conf.d# nginx -s reload

 

十四、如下图

下一步、根据报错信息提示修改php的参数

btmath啦,ldap什么的直接安装php7.0-btmath或php7.0-ldap插件即可。。。

root@david:/etc/nginx/conf.d# vim /etc/php/7.0/fpm/php.ini

post_max_size = 16M

max_execution_time = 300

max_input_time = 300

date.timezone = Asia/Shanghai

下一步,填上数据库密码,其余默认:

下一步,给你的zabbix随便起个名字:

下一步:

下一步:

下一步:

下一步:

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页