CentOS 6.5安装nagios

发布时间:2020-05-20 16:00:42 作者:wmg79
来源:网络 阅读:917

linux下nagios安装

系统环境:CentOS 6.5
安装包httpd-2.2.12.tar.bz2 ,   pcre-8.30.tar.bz2  ,   php-5.4.6.tar.bz2  ,   nagios-3.2.3.tar.gz  ,   nagios-plugins-1.4.14.tar.gz
PS: 使用的apache安装包中的pcre安装报错,所以另外下载了一个pcre包

首先yum  remove  httpd , 删除系统自带的httpd ,  关闭selinux , 关闭iptables , 启动项中删除iptables (此用于测试环境 , 生产环境不建议

安装 apache
解压httpd和pcre   tar xf httpd-2.2.12.tar.bz2 -C /usr/src      tar xf pcre-8.30.tar.bz2 -C /usr/src
安装httpd依赖包apr和apr-util , 这两个软件在httpd的srclib文件夹中 , 编译安装即可
cd /usr/src/httpd-2.2.12/srclib/apr
./configure --prefix=/usr/local/apr && make && make install && echo "apr installed"
cd /usr/src/httpd-2.2.12/srclib/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && echo "apr-util installed"
pcre同样
cd /usr/src/pcre-8.30
./configure --prefix=/usr/local/pcre && make && make install && echo "pcre installed"
编译安装apache
cd /usr/src/httpd-2.2.12
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-rewrite && make && make install && echo "apache installed"
PS: 如果编译是加入pcre会报错
安装PHP
解压PHP包   tar xf php-5.4.6.tar.bz2 -C /usr/src
编译安装
cd /usr/src/php-5.4.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs && make && make install && echo "php is ok"
cp /usr/src/php-5.4.6/php.ini-development /usr/local/php/php.ini

配置httpd.conf
DirectoryIndex index.html  改为   DirectoryIndex index.php index.html
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz   之后加入   AddType application/x-httpd-php .php

/usr/local/apache2/bin/apachectl  start   启动apache服务 , 浏览器中输入localhost可访问apache测试页
查看php是否可以使用
把apache下htdocs下的index.html该为index.php
内容是
<?php
phpinfo();
?>
重启apache服务,访问localhost

安装nagios
安装前准备
创建nagcmd用户组
groupadd  nagcmd
创建nagios用户
useradd  -G nagcmd -s /sbin/nologin  nagios
解压编译安装
tar xf nagios-3.2.3.tar.gz  -C /usr/src/
./configure --prefix=/usr/local/nagios && make all  &&  make install
make install-init 在/etc/rc.d/init.d目录下创建nagios脚本
make install-commandmode配置目录权限
make install-config安装nagios示例配置文件 , 路径在/usr/local/nagios/etc
make install-webconf /etc/httpd/conf.d目录下创建nagios.conf ,  这个文件会告诉apache 哪个路径下是nagios的文件
也可以在apache配置文件末尾添加一下代码

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">
#  SSLRequireSSL
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

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


安装nagios插件
tar xf nagios-plugins-1.4.14.tar.gz -C /usr/src
cd /usr/src/nagios-plugins-1.4.14
./configure --prefix=/usr/local/nagios  && make && make install

chown -R nagios:nagios /usr/local/nagios

apache源码包安装默认用户是daemon,加入nagcmd组中
usermod -G nagcmd daemon

启动项添加
chkconfig --add nagios
chkconfig --level 35 nagios on

创建apache目录验证文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
PS: htpasswd.users是nagios安装是make install-webconf那一步生成文件中定义好的;nagiosadmin是nagios默认用户
重启apache服务
本地主机访问localhost/nagios ,会出现输入用户名密码的验证窗口,登录之后就可以看到nagios主页了

CentOS 6.5安装nagios

推荐阅读:
  1. CentOS下如何安装Nagios
  2. 在CentOS 6.5下搭建Nagios

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux nagios centos

上一篇:开发中常用的API验证签名方式

下一篇:为什么redis是单线程的?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》