centos6.5lnmp环境 zabbix监控平台搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.5lnmp环境 zabbix监控平台搭建相关的知识,希望对你有一定的参考价值。

一:安装nginx
~安装依赖
[ro[email protected] ~]# yum -y install pcre* openssl*

编译安装
    [[email protected] ~]# ls
  anaconda-ks.cfg  install.log  install.log.syslog  nginx-1.6.3.tar.gz
    [[email protected] ~]# tar xf nginx-1.6.3.tar.gz 
    [[email protected] ~]# cd nginx-1.6.3
    [[email protected] nginx-1.6.3]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre
    [[email protected] nginx-1.6.3]# make &&make install

    验证安装
    [[email protected] nginx-1.6.3]# ls /usr/local/nginx/
    conf  html  logs  sbin


二:安装PHP

安装依赖
[[email protected] ~]# yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel openldap openldap-devel -y
获取源码包
[[email protected] ~]# tar xf php-5.6.33.tar.gz 
[[email protected] ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  nginx-1.6.3  nginx-1.6.3.tar.gz  php-5.6.33  php-5.6.33.tar.gz
[[email protected] ~]# cd php-5.6.33

编译安装
[[email protected] php-5.6.33]# ./configure --prefix=/usr/local/php-5.6 --with-config-file-path=/usr/local/php-5.6/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64  --enable-bcmath --with-ldap

[[email protected] php-5.6.33]# make &&make install

验证
[[email protected] php-5.6.33]# ls /usr/local/php-5.6/
bin  etc  include  lib  php  sbin  var

配置php
[[email protected] php-5.6.33]# cp php.ini-production /usr/local/php-5.6/etc/php.ini
[[email protected] php-5.6.33]# cp /usr/local/php-5.6/etc/php-fpm.conf.default /usr/local/php-5.6/etc/php-fpm.conf

修改php配置文件以适应zabbix的需求
vim /usr/local/php-5.6/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 = -1

三:配置nginx连接php5.6
创建文件夹放zabbix网页项目
[[email protected] ~]# mkdir /usr/local/nginx/html/zabbix
连接php
[[email protected] ~]# vi /usr/local/nginx/conf/nginx.conf

worker_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.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name 192.168.17.137;
#access_log /usr/local/nginx/logs/zabbix.access.log main;

index index.php index.html index.html;
root /usr/local/nginx/html/zabbix;

location /
{
try_files $uri $uri/ /index.php?$args;
}

location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
location /ngx_status
{
    stub_status on;
    access_log off;
}
}
}

启动nginx和php 验证连接
[[email protected] ~]# /usr/local/php-5.6/sbin/php-fpm
[[email protected] ~]# netstat -utpln |grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0: LISTEN 124237/php-fpm
[[email protected] ~]# /usr/local/nginx/sbin/nginx
[[email protected] ~]# netstat -utpln |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:
LISTEN 124243/nginx

新建个phpinfo测试文件,出现php信息 表明连接成功
[[email protected] ~]# cd /usr/local/nginx/html/zabbix/
[[email protected] zabbix]# vi index.php
[[email protected] zabbix]# cat index.php
<?php
phpinfo();
?>
技术分享图片

四:安装mysql.
安装依赖
[[email protected] ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel gcc autoconf automake zlib fiex libxml libmcrypt libtool-ltdl-devel*

[[email protected] mysql-5.6.16]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

[[email protected] mysql-5.6.16]# make &&make install
 groupadd mysql
 useradd -r -g mysql mysql
 cd /usr/local/mysql/
 chown -R mysql.mysql .
 scripts/mysql_install_db --user=mysql --ldata=/usr/local/mysql/data
     cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
        /etc/init.d/mysql start

        [[email protected] local]# mysql -uroot -p
            Enter password: 
            Welcome to the MySQL monitor.  Commands end with ; or \g.
            Your MySQL connection id is 3
            Server version: 5.6.16 Source distribution

            Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

            Oracle is a registered trademark of Oracle Corporation and/or its
            affiliates. Other names may be trademarks of their respective
            owners.

            Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

            mysql> 

五:安装zabbix
安装依赖
[[email protected] ~]# yum -y install net-snmp net-snmp-devel libxml2 libxml2-devel libcurl-devel libevent libevent libevent-devel curl curl-devel

[[email protected] ~]# tar xf zabbix-3.4.6.tar.gz
[[email protected] zabbix-3.4.6]# cd zabbix-3.4.6
[[email protected] zabbix-3.4.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libxml2

[[email protected] zabbix-3.4.6]# groupadd zabbix
[[email protected] zabbix-3.4.6]# useradd -g zabbix zabbix
[[email protected] zabbix-3.4.6]#chown -R zabbix.zabbix /usr/local/zabbix

[[email protected] conf]# cat /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=127.0.0.1
DBName=zabbix
DBUser=root
DBPassword=123123
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

/usr/local/zabbix/sbin/zabbix_server

tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 124243/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:
LISTEN 926/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 1002/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:
LISTEN 1182/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0: LISTEN 1203/sshd
tcp 0 0 0.0.0.0:10051 0.0.0.0:
LISTEN 24431/zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0: LISTEN 24501/php-fpm
tcp 0 0 :::22 :::
LISTEN 926/sshd
tcp 0 0 ::1:25 ::: LISTEN 1002/master
tcp 0 0 ::1:6010 :::
LISTEN 1182/sshd
tcp 0 0 ::1:6011 ::: LISTEN 1203/sshd
tcp 0 0 :::3306 :::
LISTEN 24357/mysqld
udp 0 0 0.0.0.0:68 0.0.0.0:* 1178/dhclient

[[email protected] zabbix-3.4.6]# cp -rf frontends/php/* /usr/local/nginx/html/zabbix/

以上是关于centos6.5lnmp环境 zabbix监控平台搭建的主要内容,如果未能解决你的问题,请参考以下文章

Zabbix监控平台生产环境案例

zabbix监控之zabbix源码部署 (安装篇)

LNMP环境搭建(基于zabbix监控软件)

解决中文环境下zabbix监控图形注释乱码

Mac+Linux+zabbix监控mysqlredis环境搭建

Zabbix监控环境搭建实现7x24监控服务