Zabbix集群监控安装
1.安装nginx+mysql+php环境
1.1安装nginx
1.1.1安装gcc、gcc-c++
[root@hadoop-01 ~]# yum install -y gcc gcc-c++
1.1.2安装openssl库
下载地址 https://www.openssl.org/source/openssl-1.0.2l.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf openssl-1.0.2l.tar.gz
[root@hadoop-01 opt]# cd openssl-1.0.2l
[root@hadoop-01 openssl-1.0.2l]# ./configure
[root@hadoop-01 openssl-1.0.2l]# make
[root@hadoop-01 openssl-1.0.2l]# make install
1.1.3安装zlib库
下载地址 http://www.zlib.net/zlib-1.2.11.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf zlib-1.2.11.tar.gz
[root@hadoop-01 opt]# cd zlib-1.2.11
[root@hadoop-01 zlib-1.2.11]# ./configure
[root@hadoop-01 zlib-1.2.11]# make
[root@hadoop-01 zlib-1.2.11]# make install
1.1.4安装pcre库
下载地址 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf pcre-8.38.tar.gz
[root@hadoop-01 opt]# cd pcre-8.38
[root@hadoop-01 pcre-8.38]# ./configure
[root@hadoop-01 pcre-8.38]# make
[root@hadoop-01 pcre-8.38]# make install
1.1.5安装nginx
下载地址 http://nginx.org/download/nginx-1.13.4.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
此处nginx的安装路路径为/opt/nginx/
openssl、zlib、pcre的路路径为各⾃自的解压路路径。可按实际情况对应修改
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf nginx-1.13.4.tar.gz
[root@hadoop-01 opt]# cd nginx-1.13.4
[root@hadoop-01 nginx-1.13.4]# ./configure \
--with-pcre=/opt/pcre-8.38/ \
--with-zlib=/opt/zlib-1.2.11/ \
--with-openssl=/opt/openssl-1.0.2l/
[root@hadoop-01 nginx-1.13.4]# make
[root@hadoop-01 nginx-1.13.4]# make install
设置nginx权限
[root@hadoop-01 ~]# chmod -R 777 /opt/nginx/
将nginx添加到环境变量量
[root@hadoop-01 ~]# vim /etc/profile
#添加如下语句句
#若已存在PATH,在原字符串串后⾯面加上:再追加$NGINX_HOME/sbin即可:
export NGINX_HOME=/opt/nginx
export PATH=$PATH:$NGINX_HOME/sbin
#保存并退出
:wq
#source⼀一下使配置⽂文件⽣生效
[root@hadoop-01 ~]# source /etc/profile
检测nginx是否安装成功
#检查配置⽂文件
[root@hadoop-01 ~]# nginx -t
#若输出如下信息,说明nginx配置⽂文件检查正常
nginx: the configuration file /opt/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx//conf/nginx.conf test is successful
#启动nginx
[root@hadoop-01 ~]# nginx
浏览器器访问主机的ip地址,若显示
Welcome to nginx!
说明nginx安装成功
1.2安装mysql
参考链接: http://www.cnblogs.com/xxoome/p/5864912.html
1.3安装php
1.3.1安装libmcrypt库
下载地址https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@hadoop-01 opt]# cd libmcrypt-2.5.8
[root@hadoop-01 libmcrypt-2.5.8]# ./configure --prefix=/usr/local
[root@hadoop-01 libmcrypt-2.5.8]# make
[root@hadoop-01 libmcrypt-2.5.8]# make install
1.3.2安装gd库(64位)
[root@hadoop-01 ~]# yum install php-gd.x86_64
1.3.3安装libxml2库
[root@hadoop-01 ~]# yum -y install libxml2-devel
1.3.4安装bzip2库
[root@hadoop-01 ~]# yum install bzip2 bzip2-devel
1.3.5安装readline库(64位)
[root@hadoop-01 ~]# yum install readline-devel.x86_64
1.3.6安装libcurl库(64位)
[root@hadoop-01 ~]# yum install libcurl-devel.x86_64
1.3.7建⽴立libmysqlclient⽂文件-⽬目录链接
[root@hadoop-01 ~]# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
[root@hadoop-01 ~]# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/
libmysqlclient.so.18
[root@hadoop-01 ~]# export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib:/usr/loc
al/mysql/lib
1.3.8安装php5.6.31
下载地址 http://cn.php.net/distributions/php-5.6.31.tar.gz
下载完成后上传⾄至/opt/⽬目录
解压并安装
此处指定php安装路路径为/usr/local/php56/,可⾃自⾏行行更更换其他安装路路径。
[root@hadoop-01 ~]# cd /opt/
[root@hadoop-01 opt]# tar -zxvf php-5.6.31.tar.gz
[root@hadoop-01 opt]# cd php-5.6.31
#添加www组及www⽤用户
[root@hadoop-01 php-5.6.31]# groupadd www
[root@hadoop-01 php-5.6.31]# useradd -g www www
[root@hadoop-01 php-5.6.31]# ./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--enable-inline-optimization \
--enable-opcache \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-readline \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir
[root@hadoop-01 php-5.6.31]# make
[root@hadoop-01 php-5.6.31]# make install
#检查php是否安装成功
[root@hadoop-01 php-5.6.31]# cd /usr/local/php56/bin/
[root@hadoop-01 bin]# ./php -v
#安装成功会显示php版本号:
PHP 5.6.31 (cli) (built: Aug 15 2017 10:27:59)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
1.3.9配置php
拷⻉贝php源码路路径下的配置⽂文件到php安装位置
[root@hadoop-01 ~]# cp /opt/php-5.6.31/php.ini-development /usr/local/php56/et
c/php.ini
修改php.ini
此处仅针对运⾏行行zabbix所需的配置
[root@hadoop-01 ~]# vim /usr/local/php56/etc/php.ini
#将对应参数改为如下值:
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone PRC
#去掉always_populate_raw_post_data前的注释
always_populate_raw_post_data = -1
#保存并退出
:wq
配置php-fpm服务
此处php-fpm56为⾃自定义的命名,可⾃自⾏行行修改。
[root@hadoop-01 ~]# cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/ph
p56/etc/php-fpm.conf
[root@hadoop-01 ~]# cp /opt/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56
[root@hadoop-01 ~]# chmod +x /etc/init.d/php-fpm56
启动php-fpm
[root@hadoop-01 ~]# service php-fpm56 start
#若显示如下信息,则启动成功
Starting php-fpm done
1.4测试nginx访问php程序
1.4.1创建php测试程序
[root@hadoop-01 ~]# mkdir /opt/nginx/html/test
[root@hadoop-01 ~]# cd /opt/nginx/html/test
[root@hadoop-01 test]# vim php.index
#写⼊入如下测试代码:
#保存并退出
:wq
1.4.2修改nginx配置⽂文件
[root@hadoop-01 ~]# vim /opt/nginx/conf/nginx.conf
在 http{ } 块中加⼊入如下配置代码:
server{
listen 81;
server_name localhost;
root html/test;
index index.html index.htm index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
保存并退出 :wq
检查配置⽂文件并重启nginx及php-fpm服务:
[root@hadoop-01 ~]# nginx -t
[root@hadoop-01 ~]# nginx -s reload
[root@hadoop-01 ~]# service php-fpm56 restart
浏览器器访问 http://__主机ip__:81 ,若显示phpinfo⻚页⾯面,则配置成功。