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

一:安装nginx
~安装依赖
[root@localhost ~]# yum -y install pcre* openssl*

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

    验证安装
    [root@localhost nginx-1.6.3]# ls /usr/local/nginx/
    conf  html  logs  sbin


二:安装PHP

安装依赖
[root@localhost ~]# yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel openldap openldap-devel -y
获取源码包
[root@localhost ~]# tar xf php-5.6.33.tar.gz 
[root@localhost ~]# 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
[root@localhost ~]# cd php-5.6.33

编译安装
[root@localhost 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

[root@localhost php-5.6.33]# make &&make install

验证
[root@localhost php-5.6.33]# ls /usr/local/php-5.6/
bin  etc  include  lib  php  sbin  var

配置php
[root@localhost php-5.6.33]# cp php.ini-production /usr/local/php-5.6/etc/php.ini
[root@localhost 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网页项目
[root@localhost ~]# mkdir /usr/local/nginx/html/zabbix
连接php
[root@localhost ~]# 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 验证连接
[root@localhost ~]# /usr/local/php-5.6/sbin/php-fpm 
[root@localhost ~]# netstat -utpln |grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0: LISTEN 124237/php-fpm 
[root@localhost ~]# /usr/local/nginx/sbin/nginx 
[root@localhost ~]# netstat -utpln |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:
 LISTEN 124243/nginx

新建个phpinfo测试文件,出现php信息 表明连接成功
[root@localhost ~]# cd /usr/local/nginx/html/zabbix/
[root@localhost zabbix]# vi index.php
[root@localhost zabbix]# cat index.php 
<?php
phpinfo();
?>
centos6.5lnmp环境 zabbix监控平台搭建

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

[root@localhost 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

[root@localhost 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

        [root@localhost 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
安装依赖
[root@localhost ~]# yum -y install net-snmp net-snmp-devel libxml2 libxml2-devel libcurl-devel libevent libevent libevent-devel curl curl-devel

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

[root@localhost zabbix-3.4.6]# groupadd zabbix
[root@localhost zabbix-3.4.6]# useradd -g zabbix zabbix
[root@localhost zabbix-3.4.6]#chown -R zabbix.zabbix /usr/local/zabbix

[root@localhost 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

[root@localhost zabbix-3.4.6]# cp -rf frontends/php/* /usr/local/nginx/html/zabbix/















本文转自偏执与柔情51CTO博客,原文链接: http://blog.51cto.com/lesliecheung/2083382,如需转载请自行联系原作者


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值