您的位置:首页 > 运维架构 > Nginx

zbbix安装 nginx+php+zabbix3.0

2016-09-09 11:03 459 查看
好久没有接触监控类的软件了,今天抽空搭建了下最新的版本首先系统环境zabbix-server-1 192.168.11.11 centos6.7mysql-server 192.168.11.5 mysql服务器独立安装

两台服务器,mysql独立安装好的,这个安装不在此介绍了 zabbix-server-1 是全新安装,安装时选择基本安装,同时在开发组件里把 服务器平台开发 桌面平台开发 附加开发 勾选上 另外为了让web页面能够支持中文显示,在语言里,添加中午字体 中文支持 [zh] 以上安装包对应的英文选项就不在此介绍了 系统安装完后

本次所需的第三方软件包以下软件包通过官网下载

zabbix-3.0.3.tar.gz http://www.zabbix.com/download.php 官网下载页面 http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download 下载链接

nginx-1.10.1.tar.gz http://nginx.org/en/download.html 官网下载页面 http://nginx.org/download/nginx-1.10.1.tar.gz 下载链接

php-5.6.22.tar.gz http://php.net/downloads.php 官网下载页面 http://php.net/get/php-5.6.22.tar.gz/from/a/mirror 下载链接列表 http://cn2.php.net/get/php-5.6.22.tar.gz/from/this/mirror 选择中国站点下载

配置yum仓库

[root@zabbix-server-1yum.repos.d]# catzabbix.repo[base]name=CentOS-$releasever- Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infrabaseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6enabled=1

yum clean all # 清除yum缓存yum makecache # 生成yum缓存开始安装nginx

#安装依赖包yuminstall pcre pcre-devel openssl openssl-develgcc-c++useradd -s/sbin/nologin -M nginxtar xf nginx-1.10.1.tar.gz ./configure--user=nginx --group=nginx --prefix=/application/nginx-1.10.1 --with-http_stub_status_module --with-http_ssl_module
make
make installln -s /application/nginx-1.10.1/ /application/nginx/application/nginx/sbin/nginx #start nginx service ps -ef|grep nginxss -lntup|grep nginx [root@zabbix-server-1 conf]# pwd/application/nginx/conf egrep -v "#|^$"nginx.conf.default > nginx.conf#修改部分配置[root@zabbix-server-1 conf]# cat nginx.confworker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 80;server_name localhost;location / {root html;index index.php index.html index.htm;}error_page 500502503504 /50x.html;location =/50x.html {root html;}location~\.(php|php5)?$ {root/application/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME /application/nginx/html$fastcgi_script_name;include fastcgi_params;}}}#杀死进程,重启服务ps -ef|grep nginx/application/nginx/sbin/nginx

安装php依赖包

yuminstall zlib-devel libxml2-devel libjpeg-devellibiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-develmysql-devel wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar zxf libiconv-1.14.tar.gzcd libiconv-1.14./configure--prefix=/usr/local/libiconvmakemakeinstall #添加epel源#https://fedoraproject.org/wiki/EPEL#上面这个位置找到对应的系统版本进入#centos 6 x86_64 https://dl.fedoraproject.org/pub/epel/6/x86_64/#https://dl.fedoraproject.org/pub/epel/ 通过这个页面下载对应的epel yum源安装包 wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm yuminstall libmcrypt-devel mhash mcrypt

安装php

tar xf php-5.6.22.tar.gzcd php-5.6.22 ./configure \--prefix=/application/php-5.6.22 \--with-mysql \--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--with-iconv-dir=/usr/local/libiconv \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--with-gettext \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization\--with-curl \--enable-mbregex \--enable-fpm \--enable-mbstring\--with-mcrypt \--with-gd \--enable-gd-native-ttf\--with-openssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--enable-short-tags \--enable-static \--with-xsl \--with-fpm-user=nginx\--with-fpm-group=nginx\--enable-ftp \--enable-opcache=no makemakeinstall ln -s /application/php-5.6.22/ /application/php[root@zabbix-server-1 php-5.6.22]# pwd/root/php-5.6.22 [root@zabbix-server-1 php-5.6.22]# cp php.ini-production /application/php/lib/php.ini[root@zabbix-server-1 php-5.6.22]# cd/application/php/etc/[root@zabbix-server-1 etc]# lspear.conf php-fpm.conf.default[root@zabbix-server-1 etc]# pwd/application/php/etc[root@zabbix-server-1 etc]# cp php-fpm.conf.default php-fpm.conf[root@zabbix-server-1 etc]# /application/php/sbin/php-fpm[root@zabbix-server-1 etc]# netstat -lntup|grep php-fpmtcp 0 0127.0.0.1:9000 0.0.0.0:* LISTEN 3689/php-fpm

安装zabbix

tar zxvf zabbix-3.0.3.tar.gz cd zabbix-3.0.3groupadd zabbixuseradd -g zabbixzabbix #安装依赖包,如果一次安装错误,就多试几次yuminstall net-snmp net-snmp-devel libssh2-develOpenIPMI-devel [root@zabbix-server-1 zabbix-3.0.3]# ./configure--enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp--with-libcurl --with-libxml2 --with-openipmi --with-ssh2 makemakeinstall [root@zabbix-server-1 zabbix-3.0.3]# egrep -v "#|^$" /usr/local/etc/zabbix_server.confLogFile=/tmp/zabbix_server.logDBHost=192.168.11.5DBName=zabbixDBUser=zabbixDBPassword=zabbixListenIP=0.0.0.0Timeout=4AlertScriptsPath=${datadir}/zabbix/alertscriptsLogSlowQueries=3000 #拷贝启动脚本cp misc/init.d/fedora/core/zabbix_*/etc/rc.d/init.d/ zabbix_server #修改配置文件vim /application/php/lib/php.inimax_execution_time= 300max_input_time = 300post_max_size =16Malways_populate_raw_post_data= -1date.timezone = Asia/Shanghai #重启php[root@zabbix-server-1 zabbix-3.0.3]# pkill -9 php-fpm[root@zabbix-server-1 zabbix-3.0.3]# /application/php/sbin/php-fpm #从zabbix源码包拷贝网站到nginx[root@zabbix-server-1 zabbix-3.0.3]# pwd/root/zabbix-3.0.3[root@zabbix-server-1 zabbix-3.0.3]# cp -rf frontends/php /application/nginx/html/zabbix/ #如果有防火墙,要么开放80端口,要么临时停止service iptablesstop #给目录设置权限chown -R nginx.nginx /application/nginx/html/

基本上zabbix服务器算是安装差不多了这里准备配置mysql服务器了,需要在mysql服务器上授权,及初始化zabbix数据库

#配置mysql服务器了。createdatabase zabbix characterset utf8 collate utf8_bin;grantallprivilegeson zabbix.*to zabbix@localhost identified by'zabbix';grantallprivilegeson zabbix.*to zabbix@'192.168.11.11' identified by'zabbix';flush privileges;quit;#按照SQL语句顺序导入SQL:mysql -uzabbix -pzabbix zabbix <zabbix-3.0.3/database/mysql/schema.sqlmysql -uzabbix -pzabbix zabbix <zabbix-3.0.3/database/mysql/images.sqlmysql -uzabbix -pzabbix zabbix <zabbix-3.0.3/database/mysql/data.sql

打开浏览器,输入以下链接http://192.168.11.11/zabbix/setup.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息