二进制安装zabbix

二进制安装zabbix

官网

zabbix官网:https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.15.tar.gz
tengine官网:https://tengine.taobao.org/download/tengine-2.2.3.tar.gz
php官网:https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm

1、安装zabbix-server 与 zabbix-agent

服务端安装zabbix-server与zabbix-agnet

shell> groupadd zabbix
shell> useradd --system -g zabbix -M -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
shell> tar -zxvf /opt/src/zabbix-5.0.14.tar.gz -C /opt/release/
shell> cd /opt/release
shell> mkdir -p /erp/zabbix/logs
shell> yum -y install gcc pcre-devel  openssl-devel mysql-devel libxml2 libxml2-devel net-snmp-devel curl-devel libevent-devel
shell> ./configure \
--prefix=/erp/zabbix \
--enable-server \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2

shell> make && make install
shell> chown -R zabbix:zabbix /erp/zabbix/*

客户端安装zabbix-agent

shell> yum -y install gcc pcre-devel  openssl-devel mysql-devel libxml2 libxml2-devel net-snmp-devel curl-devel libevent-devel
shell> ./configure --prefix=/erp/zabbix --enable-agent
shell> make && make install
shell> chown -R zabbix:zabbix /erp/zabbix/*

修改zabbix-server

shell> grep -vE "^(#|$)" zabbix_server.conf
LogFile=/erp/zabbix/logs/zabbix_server.log
PidFile=/erp/zabbix/logs/zabbix_server.pid
DBHost=192.168.30.11
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

修改zabbix-agent

shell> grep -vE "^(#|$)" zabbix_agentd.conf
PidFile=/erp/zabbix/logs/zabbix_agentd.pid
LogFile=/erp/zabbix/logs/zabbix_agentd.log
Server=127.0.0.1 #服务端IP地址
ServerActive=127.0.0.1 #服务端IP地址
Hostname=Zabbix server
UnsafeUserParameters=1
Include=/erp/zabbix/etc/zabbix_agentd.conf.d/*.cnf

启动

shell> /erp/zabbix/sbin/zabbix_server
shell> /erp/zabbix/sbin/zabbix_agentd 

2、安装php7.3(只在zabbix_server端安装)

shell> yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
shell> yum makecache
shell> yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml

修改php参数

vim /etc/opt/remi/php73/php.ini

  date.timezone=Asia/Shanghai		//设置时区
  max_execution_time=300		 	//设置执行时间(秒)	
  post_max_size=32M 				//Post数据最大容量
  max_input_time=300				//服务器接收时间的限制
  memory_limit=128M					//内存容量限制

启动php

shell> systemctl start php73-php-fpm
shell> systemctl enable php73-php-fpm

3、安装tengine(nginx)

shell> wget http://tengine.taobao.org/download/tengine-2.2.3.tar.gz
shell> tar -xvf tengine-2.2.3.tar.gz -C /opt/release
shell> mkdir -p /erp/tengine/logs
shell> cd /opt/release/tengine-2.2.3
shell> groupadd --system nginx
shell> useradd --system -g nginx -M -s /sbin/nologin -c "Nginx web server" nginx
shell> ./configure \
 --prefix=/erp/tengine/ \
 --error-log-path=/erp/tengine/logs/error.log \
 --http-log-path=/erp/tengine/logs/access.log \
 --pid-path=/var/run/nginx/nginx.pid  \
 --lock-path=/var/lock/nginx.lock \
 --with-http_ssl_module \
 --with-http_flv_module \
 --with-http_stub_status_module \
 --with-http_gzip_static_module \
 --http-client-body-temp-path=/erp/tengine/client/ \
 --http-proxy-temp-path=/erp/tengine/proxy/ \
 --http-fastcgi-temp-path=/erp/tengine/fcgi/ \
 --http-uwsgi-temp-path=/erp/tengine/uwsgi \
 --http-scgi-temp-path=/erp/tengine/ \
 --with-pcre \
 --with-stream
shell> make && make install

修改tengine配置文件

[root@host10 src]# cd /erp/tengine/conf/
[root@host10 conf]# cat nginx.conf

#user  nobody;
worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
	
	fastcgi_buffers 8 16k;
	fastcgi_buffer_size 32k;
	fastcgi_connect_timeout 300;
	fastcgi_send_timeout 300;
	fastcgi_read_timeout 300; 


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;
    keepalive_timeout  65;
		include			lyzm/*.cnf;

    }

[root@host10 conf]# mkdir lyzm
[root@host10 conf]# cat lyzm/server.cnf 


    server {
        listen       80;
        server_name  localhost;
        charset utf8;

				location / {
        		root   /usr/share/nginx/html/;
        		index index.php index.html index.htm;
   		 }

 				location ~ \.php$ {
        		root           /usr/local/nginx/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;
    		}

    }

拷贝zabbix-server的静态网页到指定目录下

shell> cp -r /opt/release/zabbix-5.0.14/ui/* /usr/share/nginx/html/

检查语法

shell> /erp/tengine/sbin/nginx -t
nginx: the configuration file /erp/tengine//conf/nginx.conf syntax is ok
nginx: configuration file /erp/tengine//conf/nginx.conf test is successful

4、配置MySQL

创建zabbix库

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@"%" identified by 'zabbix';
mysql> grant all privileges on zabbix.* to zabbix@"%";

导入库表结构

mysql -uzabbix -pzabbix zabbix < /opt/release/zabbix-5.0.14/database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < /opt/release/zabbix-5.0.14/database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < /opt/release/zabbix-5.0.14/database/mysql/data.sql

启动

你可能感兴趣的:(zabbix,php,运维,linux,zabbix)