安装zabbix及LNMP的平台的搭建
Zabbix3.0.3安装文档
环境rhel 5.8
IP:192.168.0.8
需要安装:
Nginx
Php
Mysql
Zabbix
安装步骤:
一 . Nginx1.6安装
安装nginx前要先安装pcre(支持正则表达式),最好也安装一下openssl(可以支持安全协议的站点)
[root@aps01 tmp]# tar zxvf pcre-8.35.tar.gz
[root@aps01 pcre-8.35]# ./configure
[root@aps01 pcre-8.35]# make && make install
[root@aps01 tmp]# tar zxvf openssl-1.0.1l.tar.gz
[root@aps01 openssl-1.0.1l]# ./config
[root@aps01 openssl-1.0.1l]# make && make install
[root@aps01 tmp]# tar -zxvf nginx-1.6.2.tar.gz
[root@aps01 nginx-1.6.2]# mkdir /usr/local/nginx
[root@aps01 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx
[root@aps01 nginx-1.6.2]# make && make install
查看版本信息
[root@aps01 sbin]# ./nginx -v
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@aps01 sbin]#
[root@aps01 sbin]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@aps01 sbin]# ./nginx -v
nginx version: nginx/1.6.2
[root@aps01 sbin]#
启动nginx
[root@aps01 sbin]# /usr/local/nginx/sbin/nginx
[root@aps01 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
[root@aps01 sbin]# cat /usr/local/nginx/logs/nginx.pid
7772
[root@aps01 sbin]#
关闭nginx
[root@aps01 sbin]# kill 7772
或者 kill '/usr/local/nginx/logs/nginx.pid'
Nginx配置文档的配置:
[root@zabbix 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安装
[root@RHEL58 tmp]# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
[root@RHEL58 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.安装相关依赖包
[root@zabbix 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
[root@zabbix sbin]# tar -xzvf libiconv-1.14.tar.gz
[root@zabbix sbin]# cd libiconv-1.14
[root@zabbix libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@zabbix libiconv-1.14]# make && make install
[root@zabbix zabbixsoft]# tar -xzvf libmcrypt-2.5.8.tar.gz
[root@zabbix zabbixsoft]# cd libmcrypt-2.5.8
[root@zabbix libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@zabbix libmcrypt-2.5.8]#make && make install
2.创建www用户
[root@zabbix sbin]# groupadd www
[root@zabbix sbin]# useradd -g www -s /sbin/nologin -M www
3.安装php
[root@zabbix 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
[root@zabbix php-5.5.14]# make -j8
[root@zabbix php-5.5.14]# make test
[root@zabbix php-5.5.14]# make install
配置php配置文件
[root@zabbix php-5.5.14]# cp /root/zabbixsoft/php-5.5.14/php.ini-development /usr/local/php/etc/php.ini
配置php-fpm服务
[root@zabbix etc]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@zabbix php-5.5.14]# cp /root/zabbixsoft/php-5.5.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@zabbix php-5.5.14]# chmod +x /etc/init.d/php-fpm
启动php-fpm
[root@zabbix php-5.5.14]# service php-fpm start
Starting php-fpm done
[root@zabbix php-5.5.14]#
修改相关环境变量
[root@zabbix bin]# vi ~/.bash_profile
PATH=/usr/local/php/bin:$PATH
看下版本:
[root@zabbix bin]# php -v
四.Zabbix3.0.3安装
[root@zabbix zabbix-3.0.3]# groupadd zabbix
[root@zabbix zabbix-3.0.3]# useradd -g zabbix zabbix
[root@zabbix lib]# ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
[root@zabbix lib]# /sbin/ldconfig
[root@zabbix zabbixsoft]# tar -xzvf zabbix-3.0.3.tar.gz
[root@zabbix zabbixsoft]# cd zabbix-3.0.3
./configure \
--enable-server \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2
[root@zabbix zabbix-3.0.3]# make
[root@zabbix zabbix-3.0.3]# make install
[root@zabbix zabbix-3.0.3]# mysql -uroot -proot123
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> flush privileges;
[root@zabbix zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
[root@zabbix zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
[root@zabbix 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启动服务
[root@zabbix core]# cp /root/zabbixsoft/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
[root@zabbix core]# cp /root/zabbixsoft/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
[root@zabbix sbin]# chkconfig zabbix_server on
[root@zabbix sbin]# chkconfig zabbix_agentd on
修改php配置文件:
[root@zabbix 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站点环境
[root@zabbix frontends]# cd /root/zabbixsoft/zabbix-3.0.3/frontends
[root@zabbix frontends]# cp -rf php /usr/local/nginx/html/zabbix
启动zabbix
[root@zabbix sbin]# /usr/local/sbin/zabbix_server
或 service zabbix_server start
启动nginx
[root@zabbix sbin]# /usr/local/nginx/sbin/nginx
五. 界面配置安装zabbix
浏览器打开 http://192.168.0.8/zabbix
开始web界面安装zabbix
如果遇到如下飘红的问题必须处理完毕才可以继续
上面的问题可以运行phpize动态来安装相应的php扩展
[root@zabbix gd]# pwd
/root/zabbixsoft/php-5.5.14/ext/gd
[root@zabbix gd]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
[root@zabbix gd]#
[root@zabbix gd]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir --with-freetype-dir
依照提示,
- 点击 “Download the configuration file”
- 将下载下来的文件拷贝到/usr/local/nginx/html/zabbix/conf/zabbix.conf.php
- 给其赋权限wx
[root@zabbix conf]# chmod +wx /usr/local/nginx/html/zabbix/conf/zabbix.conf.php
至此安装完成
参考文档:
http://www.cnblogs.com/zangdalei/p/5712987.html