Cents下Nagios的安装-配置Apache服务

运维 系统运维
Cents下Nagios的安装:什么是Nagios?Linux下的系统监控Nagios是怎样进行运行的?Nagios能够运行在Linux/Unix平台上,同时提供一个可选的基于WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等等。本文讲述的是配置Apache服务。

  四.配置Apache服务:

  1.备份Apache服务的主配置文件

  1.   [root@KCentOS5C ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup  
  2.  

  2.配置Apache服务的主配置文件

  1.   [root@KCentOS5C ~]# vi /etc/httpd/conf/httpd.conf  
  2.  

  这里主要改动以下这些参数:

  -----------------------------------------------------

  ServerName *:80

  配置Apache的服务器名,如果有域名的话请填写正确的服务器名。

  Include conf.d/*.conf

  确认Apache扩展配置文件的存放路径。

  -----------------------------------------------------

  3.察看Nagios网页配置模板文件

  1.   [root@KCentOS5C ~]# less nagios-2.9/sample-config/httpd.conf  
  2.  

  -----------------------------------------------------

  1.   # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER  
  2.  
  3.   # Last Modified: 11-26-2005  
  4.  
  5.   #  
  6.  
  7.   # This file contains examples of entries that need  
  8.  
  9.   # to be incorporated into your Apache web server  
  10.  
  11.   # configuration file. Customize the paths, etc. as  
  12.  
  13.   # needed to fit your system.  
  14.  
  15.   ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"  
  16.  

  设定了Nagios的CGI执行目录对应的系统路径。

  

  1.   # SSLRequireSSL  
  2.  
  3.   Options ExecCGI  
  4.  
  5.   AllowOverride None  
  6.  
  7.   Order allow,deny  
  8.  
  9.   Allow from all  
  10.  
  11.   # Order deny,allow  
  12.  
  13.   # Deny from all  
  14.  
  15.   # Allow from 127.0.0.1  
  16.  
  17.   AuthName "Nagios Access"  
  18.  
  19.   AuthType Basic  
  20.  
  21.   AuthUserFile /usr/local/nagios/etc/htpasswd.users  
  22.  

  这里指定了访问用户帐户库文件。

  1.   Require valid-user    
  2.  
  3.   Alias /nagios "/usr/local/nagios/share"  
  4.  

  设定了Nagios的网页URL对应的系统路径。

  

  1.   # SSLRequireSSL  
  2.  
  3.   Options None  
  4.  
  5.   AllowOverride None  
  6.  
  7.   Order allow,deny  
  8.  
  9.   Allow from all  
  10.  
  11.   # Order deny,allow  
  12.  
  13.   # Deny from all  
  14.  
  15.   # Allow from 127.0.0.1  
  16.  
  17.   AuthName "Nagios Access"  
  18.  
  19.   AuthType Basic  
  20.  
  21.   AuthUserFile /usr/local/nagios/etc/htpasswd.users  
  22.  

  这里指定了访问用户帐户库文件

  Require valid-user  

  -----------------------------------------------------

  基本上这个文件可以直接使用。根据这个配置文件中指定的AuthUserFile项,它指定的是通过Apache访问Nagios的合法用户的帐户名单库文件,需要使用htpasswd命令对这个名单库进行用户的添加。而默认安装环境下在/usr/local/nagios/etc/目录下是没有htpasswd.user这个文件的,所以需要手动添加。请特别注意,用root身份建立的htpasswd.user文件的权限问题,应该在建立该文件完毕后立即更改为nagios用户nagios组的所有权,并且要增加Nagios同组用户读写权限。

  4.整合Nagios网页配置文件到Apache中

  将Nagios网页配置文件作为Apache的扩展配置文件复制改名到Apache的扩展配置文件目录/etc/httpd/conf.d/目录下

  1.   [root@KCentOS5C ~]# cp nagios-2.9/sample-config/httpd.conf /etc/httpd/conf.d/nagios-httpd.conf  
  2.  

  5.建立Nagios的网页访问用户帐户文件(这里必须要与Nagios网页配置文件当中AuthUserFile指定的路径文件名一致)

  1.   [root@KCentOS5C ~]# touch /usr/local/nagios/etc/htpasswd.user  
  2.  

  6.更改Nagios网页访问用户帐户文件的属主

  1.   [root@KCentOS5C ~]# chown nagios.nagios /usr/local/nagios/etc/htpasswd.users  
  2.  

  7.对Nagios网页访问用户帐户文件增加同组成员读写权限(这主要是赋给apache这个系统用户)

  1.   [root@KCentOS5C ~]# chmod g+wr /usr/local/nagios/etc/htpasswd.users  
  2.  

  8.察看Nagios网页访问用户帐户文件的属性信息

  1.   [root@KCentOS5C ~]# ll /usr/local/nagios/etc/htpasswd.users  
  2.  
  3.   -rw-rw-r-- 1 nagios nagios 0 Oct 5 14:05 /usr/local/nagios/etc/htpasswd.users  
  4.  

  9.添加htpasswd.user用户

  我添加了一个kanecruise用户,口令是123456。

  1.   [root@KCentOS5C ~]# htpasswd -m /usr/local/nagios/etc/htpasswd.user kanecruise  
  2.  

  ------------------------------------------------------------

  New password: 123456

  Re-type new password: 123456

  Adding password for user kanecruise

  ------------------------------------------------------------

  10.察看htpasswd的使用方法,这里我就解释一些比较重要和常用的。

  1.   [root@KCentOS5C ~]# htpasswd  
  2.  

  -------------------------------------------------------------

  1.   Usage:  
  2.  
  3.   htpasswd [-cmdpsD] passwordfile username  
  4.  
  5.   htpasswd -b[cmdpsD] passwordfile username password  
  6.  
  7.   htpasswd -n[mdps] username  
  8.  
  9.   htpasswd -nb[mdps] username password  
  10.  
  11.   -c Create a new file.  
  12.  

  建立新的帐户库文件。

  1.   -n Don't update file; display results on stdout.  
  2.  
  3.   -m Force MD5 encryption of the password.  
  4.  

  添加一个MD5口令加密的新用户。

  1.   -d Force CRYPT encryption of the password (default).  
  2.  
  3.   -p Do not encrypt the password (plaintext).  
  4.  

  添加一个口令不加密的新用户。

  1.   -s Force SHA encryption of the password.  
  2.  

  添加一个SHA口令加密的新用户。

  1.   -b Use the password from the command line rather than prompting for it.  
  2.  
  3.   -D Delete the specified user.  
  4.  

  删除一个指定的用户

  1.   On Windows, NetWare and TPF systems the '-m' flag is used by default.  
  2.  

  在Windows、NetWare以及TPF这些操作系统中“-m”参数(启用MD5对口令加密)是默认使用的

  1.   On all other systems, the '-p' flag will probably not work.  
  2.  

  在其他的所有操作系统中“-p”(不对口令启用加密)参数将可能会引起失败。

  -------------------------------------------------------------

  11.检查htpasswd帐户文件

  1.   [root@KCentOS5C ~]# cat /usr/local/nagios/etc/htpasswd.users  
  2.  

 

  -------------------------------------------------------------

  用户添加正确,并且口令都以MD5的方式加密了。

  上一节:plugins插件程序    下一节:Nagios的配置文件

【编辑推荐】

Nagios被监控端的安装

Nagios的性能分析

新手入门Nagios的安装

责任编辑:zhaolei 来源: Chinaunix
相关推荐

2011-03-22 13:53:00

CentsNagios安装

2011-03-22 13:37:29

Nagios安装

2011-03-22 13:28:00

Nagios安装

2011-03-22 14:16:17

Nagios安装

2011-03-25 17:20:37

NagiosApache

2011-03-31 15:31:06

Redhat配置nagios

2014-08-06 15:25:36

LinuxNagios

2011-03-22 10:10:18

CentOSNagios安装

2010-06-01 09:51:11

2011-03-31 16:05:15

Redhat配置nagios

2011-03-21 13:01:56

LinuxNagios安装

2011-03-25 16:49:33

nagios服务

2011-08-22 12:25:05

nagios

2011-03-22 10:10:21

CentOSNagios安装

2011-03-31 16:05:18

Redhat配置nagios

2011-08-22 12:25:02

nagios

2011-03-22 10:10:16

CentOSNagios安装

2011-03-24 13:00:22

CentOSNagios安装

2011-03-24 13:00:30

2011-03-23 14:43:10

Nagiosnagios.cfg
点赞
收藏

51CTO技术栈公众号