本文中,物理机IP 192.168.1.105
虚拟linux主机ip 192.168.1.10
安装apache和php
Apache 和Php 不是安装nagios 所必须的,但是nagios提供了web监控界面,通过web监控界面可以清晰的看到被监控主机、资源的运行状态,
因此,安装一个web服务是很必要的。 
需要注意的是,nagios在nagios3.1.x版本以后,配置web监控界面时需要php的支持。
这里我们下载的nagios版本为nagios-3.4.3,因此在编译安装完成apache后,还需要编译php模块,
这里选取的php版本为php5.4.10。 [root@rhel6 ~]# tar xjf httpd-2.2.32.tar.bz2
[root@rhel6 ~]# cd httpd-2.2.32
[root@rhel6 httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu Configuring Apache Portable Runtime library ... checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/httpd-2.2.32/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
configure failed for srclib/apr
#上面安装记录我们发现,是缺少依赖组件,这里我们检查nagios所需要的支持套件的安装情况,没有安装的全部进行yum安装
[root@rhel6 httpd-2.2.32]# rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel
[root@rhel6 httpd-2.2.32]# rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel
package gcc is not installed
glibc-2.12-1.132.el6.x86_64
glibc-common-2.12-1.132.el6.x86_64
package gd is not installed
package gd-devel is not installed
package xinetd is not installed
package openssl-devel is not installed
[root@rhel6 httpd-2.2.32]# yum install -y gcc gd gd-devel xinetd openssl-devel
#编译安装
[root@rhel6 httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
[root@rhel6 httpd-2.2.32]# make && make install
测试配置文件和启动(service httpd start)
[root@rhel6 apache2]# /usr/local/apache2/bin/apachectl -t
[root@rhel6 apache2]# /usr/local/apache2/bin/apachectl
##使用其他主机访问一定要注意关闭防火墙!或者配置好防火墙策略,要不是访问不了的!
[root@rhel6 apache2]# service iptables status [root@rhel6 apache2]# service iptables stop 到此apache安装完成! z设置开机自启动
chkconfig --add httpd
chkconfig httpd --level 345 on

安装Php

# wget http://cn2.php.net/distributions/php-5.5.10.tar.gz

# tar zxvf php-5.5.10.tar.gz

# cd php-5.5.10

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

有报错如下

[root@rhel6 php-5.5.10]# yum install -y libxml2-devel libxml2

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

# make && make install

配置apache 
找到apache 的配置文件/usr/local/apache2/conf/httpd.conf 
找到:

User daemon
Group daemon

修改为

User nagios
Group nagios

然后找到

<IfModule dir_module>
  DirectoryIndex index.html
</IfModule>

修改为

<IfModule dir_module>
  DirectoryIndex index.html index.php
</IfModule>

接着增加如下内容:

AddType application/x-httpd-php .php 

为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:

 
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

2.nagios安装配置

#安装nagios前准备工作
[root@rhel6 ~]# groupadd nagios
[root@rhel6 ~]# useradd nagios -g nagios -s /sbin/nologin
[root@rhel6 ~]# mkdir /usr/local/nagios
[root@rhel6 ~]# chown -R nagios:nagios /usr/local/nagios
[root@rhel6 ~]# tar xzvf nagios-3.2.0.tar.gz
[root@rhel6 nagios-3.2.0]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios *** Configuration summary for nagios 3.2.0 08-12-2009 ***: General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs. [root@rhel6 nagios-3.2.0]# make all
[root@rhel6 nagios-3.2.0]# make install
[root@rhel6 nagios-3.2.0]# make install-init 生成init启动脚本
 [root@rhel6 nagios-3.2.0]# make install-config 生成一些模板配置文件

[root@rhel6 nagios-3.2.0]# make install-commandmode 设置相应的权限
 [root@rhel6 nagios-3.2.0]# make install-webconf

为Nagios设置Web验证的密码账号nagiosadmin  
[root@rhel6 nagios-3.2.0]/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

设置nagios开机自启动

[root@rhel6 nagios-3.2.0]# chkconfig --add nagios
[root@rhel6 nagios-3.2.0]# chkconfig nagios --level 345 on

3.nagios-plugin安装

[root@rhel6 ~]# tar xzvf nagios-plugins-1.4.14.tar.gz
[root@rhel6 ~]# cd nagios-plugins-1.4.14
[root@rhel6 nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
[root@rhel6 nagios-plugins-1.4.14]# make && make install

4.重新启动Apache和nagios

service httpd restart

service nagios restart

检查配置文件

[root@rhel6 ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 3.2.0
Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

我在做这个的时候遇到这样问题,web界面登陆用户名和密码确认都对,就是一直登陆不进去,后来资料研究发现是上图橙色文字/usr/local/nagios/etc/htpasswd.users路径错写成/usr/local/nagios/etc/htpasswd导致,具体为啥会这样我也说不清,希望大神看到解毒,修改后可以登陆。

但是此时又出现了另外一个问题 You don't have permission to access /nagios/ on this server  

出现这个问题原因很多种

1.php是否正确安装,可用php -v看下,如未安装可用使用yum一键安装 yum -y install php

2.httpd配置文件是否正确

下图中的配置如果是deny from all是万不能行的,我就是深受其害,改为allow from all,

http服务重启 service httpd restart

到此一切就能正确访问啦,欢迎大家伙沟通交流。

nagios监控的安装的更多相关文章

  1. 在Nginx中搭建Nagios监控平台

    本文只做Nginx下Nagiox安装的说明,其它关于Nagios监控的详细配置请参考我的另一篇文章[Ubuntu 10.04下构建Nagios监控平台] Nagios依赖PHP环境和perl环境.由于 ...

  2. smartmontools的安装使用和实现对磁盘的Nagios监控

    安装 首先从sourceforge下载最新的安装版本. 解压编译 $ tar -zxvf smartmontools-6.4.tar.gz $ cd smartmontools-6.4 $ ./con ...

  3. Nagios+pnp4nagios+rrdtool 安装配置nagios被监控端NRPE配置(二)

    NRPE监控插件基础 NRPE总共由两部分组成: (1).check_nrpe插件,运行在监控主机上. (2).NRPE daemon,运行在远程的linux主机上(通常就是被监控机) 整个的监控过程 ...

  4. 自动安装脚本-------------基于LVMP搭建Nagios 监控

    Mysql初始化参数(mysql-5.6.31) /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local ...

  5. Nagios 系统监控基本安装配置过程详解

    Nagios 是一款免费的开源 IT 基础设施监控系统,功能强大,灵活性强,能有效监控 Windows.Linux.VMware 和 Unix 主机状态,交换机.路由器等网络设置等.一旦主机或服务状态 ...

  6. CentOS 7.4 下安装部署Nagios监控系统详细攻略(三)

    Nagios是一个流行的电脑系统和网络监控程序,它检测主机和服务,当异常发生和解除时能提醒用户.它是基于GPLv2开发的开源软件,可免费获得及使用. nagios工作原理 nagios的功能是监控服务 ...

  7. Nagios监控平台搭建

    Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员, ...

  8. 一步步实现Nagios监控linux主机及飞信报警

    一步步实现Nagios监控linux主机及飞信报警 上篇文章介绍了在linux主机上架设nagios监控服务,并对windows主机进行服务状态变化的监控,这次我们继续上次内容.      首先实现n ...

  9. centos shell编程6一些工作中实践脚本 nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志 直接送给bc做计算 gzip innobackupex/Xtrabackup 第四十节课

    centos   shell编程6一些工作中实践脚本   nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志  直接送给bc做计算  gzip  innobacku ...

随机推荐

  1. kylin安装过程问题排查

    问题:日志报错:/usr/local/apps/kylin/tomcat/conf/.keystore (没有那个文件或目录) 解决:在kylin内置tomcat的server.xml中里边有个对ht ...

  2. Vue学习之路由vue-router小结(九)

    一.路由: 1.后端路由: 对于普通网站,所有的超链接都是URL地址,所有的URL地址都对应服务器上对应的资源: 2.前端路由: 对于单页面应用程序来说,主要通过URL中的hash(#号)来实现不同页 ...

  3. JavaScript 之 创建元素

    方式一: 使用  document.write() 语法格式: document.write('新设置的内容<p>标签也可以生成</p>'); 注意:在使用方式的时候,writ ...

  4. restframework详细

    1.写视图的方法 1.1第一种:原始APIView url(r'^login/$',account.LoginView.as_view()), from rest_framework.views im ...

  5. Linux-crontab定时执行脚本配置

    crontab是一个可以根据自己配置的命令定时执行脚本的服务 安装crontab(centos) yum install Vixie-cron yum install crontabs vixie-c ...

  6. Httpd服务进阶知识-基于Apache Modele的LAMP架构之Discuz!案例

    Httpd服务进阶知识-基于Apache Modele的LAMP架构之Discuz!论坛案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装依赖包及数据库  博主推荐阅读: ...

  7. 自动化渗透测试工具(Cobalt Strike)3.1 最新破解版

    自动化渗透测试工具(Cobalt Strike)3.1 最新破解版[附使用教程] Cobalt Strike是一款专业的自动化渗透测试工具,它是图形化.可视化的,图形界面非常友好,一键傻瓜化使用MSF ...

  8. 使用salt-stack指定IP添加系统用户为root的权限

    指定多台要授权的用户,指定root权限 salt -L '192.168.3.212' cmd.run 'useradd fengniao -u 2000' salt -L '192.168.3.21 ...

  9. seaborn---画热力图

    1.引用形式: seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False, annot=None ...

  10. python预课05 爬虫初步学习+jieba分词+词云库+哔哩哔哩弹幕爬取示例(数据分析pandas)

    结巴分词 import jieba """ pip install jieba 1.精确模式 2.全模式 3.搜索引擎模式 """ txt ...