安装zabbix及LNMP的平台的搭建

Posted

tags:

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

Zabbix3.0.3安装文档

环境rhel 5.8

IP:192.168.0.8

 

 

需要安装:

nginx

php

mysql

Zabbix

 

 

安装步骤:

 

一 .  Nginx1.6安装

 

 

 

安装nginx前要先安装pcre(支持正则表达式),最好也安装一下openssl(可以支持安全协议的站点)

[[email protected] tmp]# tar zxvf pcre-8.35.tar.gz

[[email protected] pcre-8.35]# ./configure

[[email protected] pcre-8.35]# make && make install

 

[[email protected] tmp]# tar zxvf openssl-1.0.1l.tar.gz

[[email protected] openssl-1.0.1l]# ./config

[[email protected] openssl-1.0.1l]# make && make install

 

[[email protected] tmp]# tar -zxvf nginx-1.6.2.tar.gz

[[email protected] nginx-1.6.2]# mkdir /usr/local/nginx

[[email protected] nginx-1.6.2]# ./configure --prefix=/usr/local/nginx

[[email protected] nginx-1.6.2]# make && make install

 

 

 

 

 

查看版本信息

[[email protected] sbin]# ./nginx -v

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

[[email protected] sbin]#

 

 

 

[[email protected] sbin]# ln -s /usr/local/lib/libpcre.so.1 /lib64

[[email protected] sbin]# ./nginx -v

nginx version: nginx/1.6.2

[[email protected] sbin]#

 

 

 

启动nginx

 

[[email protected] sbin]# /usr/local/nginx/sbin/nginx

[[email protected] sbin]# ps -ef | grep nginx       

root      7772     1  0 15:08 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

nobody    7773  7772  0 15:08 ?        00:00:00 nginx: worker process     

root      7775 19121  0 15:08 pts/6    00:00:00 grep nginx

[[email protected] sbin]# cat /usr/local/nginx/logs/nginx.pid

7772

[[email protected] sbin]#

 

 

 

关闭nginx

 

[[email protected] sbin]# kill 7772

或者 kill ‘/usr/local/nginx/logs/nginx.pid‘

 

 

 

 

Nginx配置文档的配置:

 

 

[[email protected] conf]# 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.php index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        location ~ \\.(php|php5)?$ {

            root           /usr/local/nginx/html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

           # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;

            include        fastcgi_params;

            }

        }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

二 . mysql 5.6安装

 

[[email protected] tmp]# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm

[[email protected] tmp]# rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm

 

更改root用户的密码:

mysqladmin -u root -p password mysql123

 

 

 

 

 

 

 

 

三 . php 5.5.14安装

 

1.安装相关依赖包

 

[[email protected] sbin]# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel

 

 

 

[[email protected] sbin]# tar -xzvf libiconv-1.14.tar.gz

[[email protected] sbin]# cd libiconv-1.14

[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[[email protected] libiconv-1.14]# make && make install

 

[[email protected] zabbixsoft]# tar -xzvf libmcrypt-2.5.8.tar.gz

[[email protected] zabbixsoft]# cd libmcrypt-2.5.8

[[email protected] libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt

 

[[email protected] libmcrypt-2.5.8]#make && make install

2.创建www用户

 

[[email protected] sbin]# groupadd www

[[email protected] sbin]# useradd -g www -s /sbin/nologin -M www

 

 

3.安装php

[[email protected] zabbixsoft]# tar -xzvf php-5.5.14.tar.gz

 

cd php-5.5.14

 

 

 

 

 

./configure \\

--prefix=/usr/local/php \\

--with-config-file-path=/usr/local/php/etc \\

--enable-inline-optimization \\

--disable-debug \\

--disable-rpath \\

--enable-shared \\

--enable-opcache \\

--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-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 \\

--without-pear \\

--disable-phar \\

--with-gd \\

--enable-gd-native-ttf \\

--with-png-dir \\

--with-freetype-dir \\

--with-jpeg-dir

 

 

 

 

 

[[email protected] php-5.5.14]# make -j8

 

[[email protected] php-5.5.14]# make test

 

[[email protected] php-5.5.14]# make install

 

 

 

 

配置php配置文件

[[email protected] php-5.5.14]# cp /root/zabbixsoft/php-5.5.14/php.ini-development /usr/local/php/etc/php.ini

 

配置php-fpm服务

[[email protected] etc]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

 

[[email protected] php-5.5.14]# cp /root/zabbixsoft/php-5.5.14/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm

[[email protected] php-5.5.14]# chmod +x /etc/init.d/php-fpm

 

 

 

 

 

 

启动php-fpm

 

 

[[email protected] php-5.5.14]# service php-fpm start

Starting php-fpm  done

[[email protected] php-5.5.14]#

 

 

修改相关环境变量

[[email protected] bin]# vi ~/.bash_profile

 

PATH=/usr/local/php/bin:$PATH

 

 

看下版本:

 

[[email protected] bin]# php -v

 

 

 

 

 

 

 

 

 

 

四.Zabbix3.0.3安装

 

 

 

[[email protected] zabbix-3.0.3]# groupadd zabbix

[[email protected] zabbix-3.0.3]# useradd -g zabbix zabbix

 

[[email protected] lib]# ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

[[email protected] lib]# /sbin/ldconfig

 

 

[[email protected] zabbixsoft]# tar -xzvf zabbix-3.0.3.tar.gz

[[email protected] zabbixsoft]# cd zabbix-3.0.3

 

 

./configure \\

--enable-server \\

--enable-agent \\

--with-mysql \\

--enable-ipv6 \\

--with-net-snmp \\

--with-libcurl \\

--with-libxml2

 

[[email protected] zabbix-3.0.3]# make

[[email protected] zabbix-3.0.3]# make install

 

 

[[email protected] zabbix-3.0.3]# mysql -uroot -proot123

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> grant all privileges on zabbix.* to [email protected] identified by ‘zabbix‘;

mysql> flush privileges;

 

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

 

 

配置zabbix配置文件

Vi   /usr/local/etc/zabbix_server.conf

 

DBName=zabbix #数据库名称 

DBUser=zabbix #数据库用户名 

DBPassword=jiayuan.com #数据库密码 

ListenIP=localhost #数据库ip地址 

AlertScriptsPath=/usr/local/share/zabbix/alertscripts

 

 

 

 

设置zabbix启动服务

[[email protected] core]# cp /root/zabbixsoft/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server

[[email protected] core]# cp /root/zabbixsoft/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd

 

[[email protected] sbin]# chkconfig zabbix_server on

[[email protected] sbin]# chkconfig zabbix_agentd on

 

 

 

 

修改php配置文件:

[[email protected] lib]# vi /usr/local/php/etc/php.ini

 

post_max_size 16M

max_execution_time 300

max_input_time 300

date.timezone =Asia/Shanghai

 

 

配置web站点环境

[[email protected] frontends]# cd /root/zabbixsoft/zabbix-3.0.3/frontends

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

 

 

 

启动zabbix

[[email protected] sbin]# /usr/local/sbin/zabbix_server

  或 service zabbix_server start

 

启动nginx

 

[[email protected] sbin]#  /usr/local/nginx/sbin/nginx

 

 

 

 

 

 

 

 

 

五. 界面配置安装zabbix

 

浏览器打开 http://192.168.0.8/zabbix

 

开始web界面安装zabbix

 

 

 

 

 

 

 

如果遇到如下飘红的问题必须处理完毕才可以继续

 

 

 

 

 

 

 

 

 

 

 

 

上面的问题可以运行phpize动态来安装相应的php扩展

 

[[email protected] gd]# pwd

/root/zabbixsoft/php-5.5.14/ext/gd

 [[email protected] gd]# /usr/local/php/bin/phpize

Configuring for:

PHP Api Version:         20121113

Zend Module Api No:      20121212

Zend Extension Api No:   220121212

[[email protected] gd]#

[[email protected] gd]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir --with-freetype-dir

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

依照提示,

  1. 点击 “Download the configuration file”
  2. 将下载下来的文件拷贝到/usr/local/nginx/html/zabbix/conf/zabbix.conf.php
  3. 给其赋权限wx

[[email protected] conf]# chmod +wx /usr/local/nginx/html/zabbix/conf/zabbix.conf.php

 

 

 

至此安装完成

 

 

 

 

 

 

 

参考文档:

http://www.cnblogs.com/zangdalei/p/5712987.html

 

http://wenku.baidu.com/link?url=0PxW49msf5yfiDeQZ8A2QiBDa12FrOFHSjI51bo-llJW6u1kFPR_IYsTQ6FOCRJyAMt2ggbIvKXj53fZEiSY-pZ-AdpCcUqfsCOTLinJrWS

 

以上是关于安装zabbix及LNMP的平台的搭建的主要内容,如果未能解决你的问题,请参考以下文章

LNMP平台搭建及优化

Centos 6 编译安装LNMP

Centos 6 编译安装LNMP

Centos 6 编译安装LNMP

编译安装Zabbix 5.0 LTS

基于rhel7.2的Zabbix平台搭建和部署