linux上nagios安装完整版

监控服务器端的安装部署
一、apache的安装
下载httpd-2.2.15.tar.gz
gunzip httpd-2.2.15.tar.gz
tar xvf httpd-2.2.15.tar
cd httpd-2.2.15
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-mpm=worker
make
make install
安装完后增加nagios用户
groupadd nagios
useradd -g nagios -d /home/nagios -m nagios
passwd nagios
修改httpd.conf中的user group为下面的参数
User nagios
Group nagios
修改ServerName=ip(服务器的ip地址):80
mkdir /usr/local/nagios
chown nagios:nagios /usr/local/nagios

二、安装php+mysql(mysql可以不用安装,为了以后使用最好先安装)
安装mysql
rpm -ivh MySQL-server-community-5.1.46-1.rhel5.i386.rpm
rpm -ivh MySQL-devel-community-5.1.46-1.rhel5.i386.rpm
rpm -ivh MySQL-client-community-5.1.46-1.rhel5.i386.rpm

安装php前先安装以下软件:
安装zlib (安装libpng和gd前需要先安装zlib),
gunzip zlib-1.2.3.tar.gz
tar xvf  zlib-1.2.3.tar
cd zlib-1.2.3
./configure  --prefix=/usr/local/zlib
make
make install

安装libpng,
gunzip libpng-1.2.18.tar.gz
tar xvf libpng-1.2.18.tar
cd libpng-1.2.18
./configure --prefix=/usr/local/libpng
make
make install

安装freetype
gunzip freetype-2.3.12.tar.gz
tar xvf freetype-2.3.12.tar
cd freetype-2.3.12
./configure --prefix=/usr/local/freetype
make
make install

4. 安装jpeg
gunzip jpegsrc.v6b.tar.gz
tar xvf jpegsrc.v6b.tar
cd jpeg-6b
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install

5. 安装gd,
gunzip gd-2.0.35.tar.gz
tar xvf gd-2.0.35.tar
cd gd-2.0.35
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib
//编译过程中会看到如下信息
** Configuration summary for gd 2.0.35:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
//可以看到png 、 jpeg 、 freetype都已经安装上了
make
make install

上面软件都安装好后,现在就可以安装php了
gunzip php-5.3.2.tar.gz
tar xvf php-5.3.2.tar
cd php-5.3.2
./configure --prefix=/usr/local/php5 --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local/gd --with-zlib --with-libpng=/usr/local/libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-sockets --with-iconv --enable-mbstring --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
make
make install
安装完后执行
cp php.ini-development  /usr/local/php5/etc/php.ini
最后修改httpd.conf,使apache能使用php,增加如下参数
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

三、安装nagios软件
下载nagios-3.2.1.tar.gz
gunzip nagios-3.2.1.tar.gz
tar xvf nagios-3.2.1.tar
cd nagios-3.2.1
./configure --prefix=/usr/local/nagios   --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/include
make all                             //编译nagios
make install                        //安装主要的程序,CGI及HTML文件
make install-init                  //在/etc/rc.d/init.d安装启动脚本
make install-commandmode          //给外部命令访问nagios配置文件的权限
make install-config              //将配置文件的例子复制到nagios的安装目录

验证程序是否被正确安装
看是否存在etc,bin,sbin,share,var五个目录
bin     Nagios执行程序所在目录,nagios文件即为主程序
etc     Nagios配置文件位置
sbin    Nagios cgi文件所在目录,执行外部命令所需文件所在的目录
share  Nagios网页文件所在的目录
var     Nagios日志文件,spid等文件所在的目录

四、安装nagios插件
下载nagios-plugins-1.4.14.tar.gz
gunzip nagios-plugins-1.4.14.tar.gz
tar xvf nagios-plugins-1.4.14.tar
cd nagios-plugins-1.4.14
./configure --prefix=/usr/local/nagios-plugins
make all
make install
安装完成以后在/usr/local/nagios-plugins会产生一个libexec的目录,将该目录全部移动到/usr/local/nagios目录下
cp -r /usr/local/nagios-plugins/libexec /usr/local/nagios/libexec
chown -R nagios:nagios /usr/local/nagios/

五、安装imagepak-base
下载imagepak-base.tar.gz
gunzip imagepak-base.tar.gz
tar xvf imagepak-base.tar
解压以后是一个base目录,将该目录拷贝到 /usr/local/nagios/share/images/logos目录下
cp -r base /usr/local/nagios/share/images/logos
chown -R nagios:nagios /usr/local/nagios/share/images/logos

六、配置httpd.conf使用nagios
在httpd.conf后面加入如下内容
vi /usr/local/apache2/conf/httpd.conf       
#Setting for nagios
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>

Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>

对增加后的参数进行验证
/usr/local/apache2/bin/apachectl -t           //检查配置文件是否正确
生成apache访问的认证文件并启动apache进行验证
/usr/local/apache2/bin/htpasswd -c /usr/local/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值