zabbix6.0-nginx代理
1、MySQL安装
1.1 详见MySQL安装
1.2 创建zabbix初始数据库
# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
2、nginx安装
2.1 下载nginx安装包
wget http://nginx.org/download/nginx-1.24.0.tar.gz
或nginx官网下载,上传之服务器
2.2 安装相关依赖
#c编译器
yum -y install gcc gcc-c++ autoconf automake make
#解析正则的pcre库
yum install -y pcre pcre-devel
#添加对gzip的支持
yum install -y zlib zlib-devel
#SSL
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.3 nginx包解压并进入解压目录
tar -xvf nginx-1.24.0.tar.gz cd /usr/local/nginx/nginx-1.24.0
2.4 nginx编译安装
#需创建nginx用户
groupadd --system nginx
useradd --system -g nginx -d /usr/lib/nginx -s /sbin/nologin -c "Nginx Monitoring System"
#编译安装
nginx ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-stream make&&make install
2.5 nginx基础命令
#查看nginx语法是否正确
./nginx -t
#启动nginx
./nginx
#刷新配置文件
./nginx -s reload
#查看版本 任意地方可执行
nginx -V
#正常关闭
./nginx -s quit
#强制关闭
./nginx -s stop
#查看nginx进程
ps aux|grep nginx
3、php安装
3.1 php安装
因为centos7自带php版本过低,zabbix6.0需要7.2以上版本的php,需要安装额外的库,remi库
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php74
yum -y install php php-bcmath php-gd php-xml php-mbstring php-mysqlnd php-ldap php-fpm
yum -y install curl-devl libxml2 libxml2-devel
3.2 修改php参数
vi /etc/php.ini
修改post_max_size为16M
修改max_execution_time为300
修改max_input_time为300
修改date.timezone为Asia/Shanghai
4、zabbix安装
4.1 下载zabbix安装包
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.17.tar.gz
或zabbix官网下载
4.2 安装相关依赖
yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel yum -y install unixODBC-devel net-snmp-devel libevent-devel libxml2-devel libcurl-devel gcc gcc-c++ mysql-devel libssh2-devel go curl-devel yum -y install php-gd php-mysqlnd php-bcmath php-xml php-mbstring yum -y install mysql-devel yum -y install libxml2 libxml2-devel yum -y install net-snmp-devel
4.3 创建zabbix用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
4.4 解压编译安装
tar -xzvf zabbix-6.0.17.tar.gz
cd /usr/local/zabbix/zabbix-6.0.17
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql --with-libcurl --with-libxml2 --enable-webservice
make install
#make install报错 use option -std=c99 or -std=gnu99 to compile your code
运行下列命令后重新编译安装
export CFLAGS="-std=gnu99"
4.5 数据导入
-p'password'替换为数据库zabbix用户的密码
mysql -uzabbix -ppassword zabbix < /usr/local/zabbix/zabbix-6.0.17/database/mysql/schema.sql
mysql -uzabbix -ppassword zabbix < /usr/local/zabbix/zabbix-6.0.17/database/mysql/images.sql
mysql -uzabbix -ppassword zabbix < /usr/local/zabbix/zabbix-6.0.17/database/mysql/data.sql
5、web配置
5.1 复制前端文件
mkdir -p /usr/local/nginx/html/zabbix
cp -r /usr/local/zabbix/zabbix-6.0.17/ui/* /usr/local/nginx/html/zabbix
5.2 修改nginx.conf配置
vi /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 13000;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location / {
root html/zabbix;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .*\.(php|php5)?$ { #重要
root html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
5.3 检查nginx并重新加载
cd /usr/local/nginx/sbin ./nginx -t ./nginx -s reload
5.4 访问本机IP+端口
192.168.244.5:13000/setup.php