文章目录
3.1.4 主配置文件nginx.conf中指定包含其他扩展配置文件,从而简化nginx主配置文件,实现多个站点功能
5.4 拷贝zabbix客户端启动脚本到/etc/init.d目录下
zabbix5.0切换到中文界面后,部分在图片上显示的文字会出现中文乱码:
1.zabbix-server编译报错如下:configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
2.zabbix-server报错如下:configure: error: Unable to use libevent (libevent check failed)
一、zabbix前景
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案;
zabbix能监视各种网络参数,保证服务器系统的安全运营;
并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题;
zabbix由2部分构成: zabbix server运行在被监控端的zabbix agent。
zabbix的主要特点:
- - 安装与配置简单,学习成本低
- - 支持多语言(包括中文)
- - 免费开源
- - 自动发现服务器与网络设备
- - 分布式监视以及WEB集中管理功能
- - 可以无agent监视
- - 用户安全认证和柔软的授权方式
- - 通过WEB界面设置或查看监视结果
- - email等通知功能等等
二、安装环境
本文章所须要安装软件包都存储在/usr/src/zabbix_install目录下的
- LNMP环境 (Linux 7.5;Nginx 版本1.17.8;php 版本7.2.0及以上;mysql版本 5.5.62及以上)
- zabbix-server(版本5.0)
- zabbix-agentd
IP地址 | 角色 | 安装软件 | 操作系统 |
192.168.1.128 | 服务器端+被监控端+数据库存储 | zabbix-serve、zabbix-agent、mysql,php,nginx | Centos 7.5 |
192.168.1.129 | 被监控端 | zabbix-agent | Centos 7.5 |
三、LNMP安装
3.1 Nginx安装
3.1.1 安装依赖环境
[root@zabbix-server ~]# yum install readline-devel pcre-devel openssl-devel gcc -y
3.1.2 下载nginx源码包及解压编译
只使用nginx提供简单的web页面启动即可
[root@zabbix-server zabbix_install]# wget http://nginx.org/download/nginx-1.17.8.tar.gz
[root@zabbix-server zabbix_install]# tar zxvf nginx-1.17.8.tar.gz
[root@zabbix-server zabbix_install]# cd nginx-1.17.8
[root@zabbix-server nginx-1.17.8]# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-stream \
--with-stream_ssl_module \
--with-threads \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module
[root@zabbix-server nginx-1.17.8]# gmake -j 2 && gmake install
3.1.3 创建相应用户及目录
[root@zabbix-server nginx-1.17.8]# useradd -s /sbin/nologin -M nginx
[root@zabbix-server nginx-1.17.8]# mkdir -p /data/logs/nginx
//创建存放每个站点文件的目录
[root@zabbix-server nginx-1.17.8]# mkdir /usr/local/nginx/conf/vhost
//创建zabbix存放页面目录,后面配置zabbix-server的web界面会用到
[root@zabbix-server nginx-1.17.8]# mkdir -p /data/web/zabbix
3.1.4 主配置文件nginx.conf中指定包含其他扩展配置文件,从而简化nginx主配置文件,实现多个站点功能
[root@zabbix-server nginx-1.17.8]# cat > /usr/local/nginx/conf/nginx.conf << \EOF
user nginx nginx;
worker_processes 4;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 65535;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
#charset utf-8;
server_names_hash_bucket_size 128;
large_client_header_buffers 4 64k;
client_header_buffer_size 32k;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_addr $upstream_response_time $request_time';
sendfile on;
tcp_nopush on;
client_max_body_size 1024m;
tcp_nodelay on;
keepalive_timeout 100;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_types text/* text/css application/javascript application/x-javascript;
server_tokens off;
#创建多个配置文件
include /usr/local/nginx/conf/vhost/*.conf;
}
EOF
3.1.5 配置zabbix站点nginx虚拟目录
[root@zabbix-server nginx-1.17.8]# cat > /usr/local/nginx/conf/vhost/web.zabbix.com.conf << \EOF
server {
listen 80;
server_name web.zabbix.com;
access_log /data/logs/nginx/zabbix_access.log main;
error_log /data/logs/nginx/zabbix_error.log error;
location / {
root /data/web/zabbix;
index index.php index.html index.htm ;
}
location ~ \.php$ {
root /data/web/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
fastcgi_index index.php;
include fastcgi_params;
}
}
EOF
3.1.6 检测语法及启动
[root@zabbix-server nginx-1.17.8]# /usr/local/nginx/sbin/nginx -t
[root@zabbix-server nginx-1.17.8]# /usr/local/nginx/sbin/nginx
3.2 MySQL安装
3.1.1 相关安装配置
参考文章- msyql安装
3.1.2 创建zabbix数据库及添加权限
[root@zabbix-server zabbix_install]# mysql -uroot -p123456
.......
:49: root@localhost:[(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.07 sec)
:49: root@localhost:[(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected, 2 warnings (0.03 sec)
:49: root@localhost:[(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3.3 php-fpm安装
3.3.1 安装php所需依赖
[root@zabbix-server zabbix_install]# yum -y install freetype-devel libpng-devel libjpeg-devel libxml2-devel bzip2-devel libcurl-devel
3.3.2 安装mcrypt扩展
源码包下载地址 : libmcrypt与php源码包下载
通过xftp或 rz 上传到/usr/src/zabbix_install目录下
[root@zabbix-server zabbix_install]# tar zxf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7
[root@zabbix-server libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install
3.3.3 安装php
[root@zabbix-server zabbix_install]# tar zxvf php-7.2.0.tar.gz
[root@zabbix-server zabbix_install]# cd php-7.2.0
[root@zabbix-server php-7.2.0]#./configure --prefix=/usr/local/php7.2 \
--with-config-file-path=/etc --with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt=/usr/local/libmcrypt \
--with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib \
--with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml \
--enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization \
--enable-mbregex --enable-fpm --enable-mbstring --enable-ftp \
--enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets \
--with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext \
--enable-session --with-curl --with-ldap && make && make install
这里大部分参数都做了安装,具体配置参数详解自行百度。
编译过程时间较久,请耐心等待编译完成!!!