第一步安装apache

root@root01-virtual-machine:/etc/apache2/conf-available# vi charset.conf

可修改apache服务器的编码格式

将最后行的 #AddDefaultCharset UTF-8 前面的#去掉,使用UTF-8编码,当然也可以把 UTF-8改成别的编码

etc/apache2/sites-available/default
这个是网站目录配置,想更改网站目录的话,就修改这个,默认的网站目录是/var/www(所有者为root,所以修改起来很不方便)

安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。

发现在 /etc /apache2/sites-enabled/000-default中,里面有这样的内容:

<VirtualHost *> 
ServerAdmin webmaster @localhost  
DocumentRoot /var/www/
 第二种方法:上传httpd软件
tar -zxvf httpd-2.2.26.tar.gz
cd httpd-2.2.22
./configure --prefix=/usr/local/apache
make

make install

root@root01-virtual-machine:/opt/httpd-2.2.26# ./usr/local/apache/bin/apachectl -t       进行检查
 Syntax OK
启动apache命令
 
第二步 安装nadios

基础支持套件:gcc glibc glibc-common gd gd-devel xinetd openssl-devel

# rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel

如果系统中没有这些套件,使用yum 安装

# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel

所用软件

nagios-2.9.tar.gz

nagios-plugins-1.4.9.tar.gz

nrpe-2.8.1.tar.gz

NSClient++-0.2.7.zip

注:

前三个的下载地址:[url]http://www.nagios.org[/url],

后一个的[url]http://sourceforge.net/projects/nscplus[/url]

总体目标

具体信息如下

nagios是不是很强大,基本上对监控对象的任何信息都可以一手掌握了.而且不用登陆到目的机就可以看到那台机器私密的”本地信息”

需要在监控机配置好apache和php

安装nagios

最后达到如下的功能

监控机自身的信息,包括主机信息以及对外提供的服务

被监控机对外提供的服务

root@root01-virtual-machine:/opt# ls nagios  nagios-3.3.1.tar.gz  redis-2.6.8  redis-2.6.8.tar.gz

root@root01-virtual-machine:/opt# cd nagios/

root@root01-virtual-machine:/opt/nagios# ./configure --prefix=/usr/local/nagios  编译,指定安装目录

Nagios executable:  nagios

Nagios user/group:  nagios,nagios

Command user/group:  nagios,nagios

--创建用户和组

#groupadd nagios#useradd -g nagios nagios

#passwd nagios

[root@Dave nagios-3.2.1]# cd ./base

[root@Dave base]# pwd

/nagios/nagios-3.2.1/base

root@root01-virtual-machine:/opt/nagios/base# make all

*** Compile finished ***

If the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options):

make install      - This installs the main program, CGIs, and HTML files

使用make install来安装主程序,CGI和HTML文件 

make install-init      - This installs the init script in /etc/init.d

 使用make install-init/etc/rc.d/init.d安装启动脚本

make install-commandmode      - This installs and configures permissions on the        directory for holding the external command file

使用make install-commandmode来配置目录权限 

使用make install-commandmode来安装示例配置文件,安装的路径是/usr/local/nagios/etc.

make install-config      - This installs *SAMPLE* config files in /usr/local/nagios/etc

*** Support Notes *******************************************

If you have questions about configuring or running Nagios, please make sure that you:

- Look at the sample config files      - Read the documentation on the Nagios Library at:            http://library.nagios.com

before you post a question to one of the mailing lists. Also make sure to include pertinent information that could help others help you.  This might include:

- What version of Nagios you are using      - What version of the plugins you are using      - Relevant snippets from your config files      - Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:

http://support.nagios.com

*************************************************************

Enjoy.

很多人都不注意安装过程中的输出信息,直到make install出错了才到处找人求救,而实际上输出的内容包含很多有价值的信息,例如安装路径,版本,每一步做什么,接下来的步骤等.尤其是输出的最后一屏信息,我个人建议好好的读一下.例如上面就列出了很多有价值的信息,我们只需要按照他说的做就行了.

root@root01-virtual-machine:/opt/nagios# make install

cd ./base && make install make[1]: 正在进入目录 `/opt/nagios/base' make install-basic make

make[1]: *** [install] 错误 1

make[1]:正在离开目录 `/opt/nagios/html'

make: *** [install] 错误 2                        下边的命令式解决的办法

root@root01-virtual-machine:/opt/nagios# sed -i 's:for file in includes/rss/\*;:for file in includes/rss/\*.\*;:g' ./html/Makefile

root@root01-virtual-machine:/opt/nagios# sed -i 's:for file in includes/rss/extlib/\*;:for file in includes/rss/extlib/\*.\*;:g' ./html/Makefile

root@root01-virtual-machine:/opt/nagios#  make fullinstall

cd ./base && make install make[1]: 正在进入目录 `/opt/nagios/base' make install-basic make

*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options):

make install-init      - This installs the init script in /etc/init.d

make install-commandmode      - This installs and configures permissions on the        directory for holding the external command file

make install-config      - This installs sample config files in /usr/local/nagios/etc

make[1]:正在离开目录 `/opt/nagios' /usr/bin/install -c -m 755 -d -o root -g root /etc/init.d /usr/bin/install -c -m 755 -o root -g root daemon-init /etc/init.d/nagios

*** Init script installed ***

/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf /usr/bin/install: 无法创建普通文件"/etc/httpd/conf.d/nagios.conf": 没有那个文件或目录 make: *** [install-webconf] 错误 1

root@root01-virtual-machine:/opt/nagios# mkdir -p /etc/httpd/conf.d      创建所缺的目录文件

root@root01-virtual-machine:/opt/nagios# make fullinstall

也可以在make install 的时候我们要分别执行:

make install

make install-init

make install-commandmode

make install-config

make install-webconf

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read the documentation for more information on how to actually define services, hosts, etc. to fit your particular needs.

验证程序是否被正确安装。切换目录到安装路径(这里是/usr/local/nagios),看是否存在 etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。

root@root01-virtual-machine:/usr/local/nagios# ls
bin  etc  libexec  sbin  share  var

bin

Nagios执行程序所在目录,nagios文件即为主程序

etc

Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件

sbin

Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录

Share

Nagios网页文件所在的目录

Var

Nagios日志文件、spid 等文件所在的目录

var/archives

Empty directory for the archived logs

var/rw

Empty directory for   the external command file

安装nagios插件

http://www.nagios.org/download/plugins下载nagios-plugins-1.5.tar.gz

root@root01-virtual-machine:~# tar -zxvf nagios-plugins-1.5.tar.gz

cd nagios-plugins-1.5 编译,指定路径为之前nagios的安装路径 # ./configure --prefix=/usr/local/nagios

make 安装 make install ls /usr/local/nagios/libexec/ 会显示安装的插件文件,即所有的插件都安装在libexec这个目录下

安装与配置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。

安装Php

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

# tar zxvf php-5.4.10.tar.gz

# cd php-5.4.10

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

# make && make install

配置apache

root@root01-virtual-machine:/usr/local/apache/conf# grep ^User /usr/local/apache/conf/httpd.conf User daemon      
  将apache的运行用户加到nagios组里面 从httpd.conf中过滤出当前的apache运行用户
  root@root01-virtual-machine:/usr/local/apache/conf# usermod -G nagios daemon     

然后找到

<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 //用于此目录访问身份验证的文件
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
Require valid-user
</Directory>

d. 创建apache目录验证文件

root@root01-virtual-machine:/opt/nagios# make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

*** Nagios/Apache conf file installed ***

root@root01-virtual-machine:/opt/nagios# htpasswd  没有安装httpd会有如下提示

程序“htpasswd”尚未安装。 您可以使用以下命令安装: apt-get install apache2-utils

root@root01-virtual-machine:/opt/nagios# apt-get install apache2-utils  安装httpd

在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:

# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david

这样就在/usr/local/nagios/etc 目录下创建了一个htpasswd 验证文件,当通过http://192.168.1.108/nagios/ 主监控机,访问时就需要输入用户名和密码了。

root@root01-virtual-machine:/opt/nagios# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios New password: Re-type new password: Adding password for user nagios                  上述命令为Nagios设置web验证的密码    第一次添加用户用-c,以后在添加不可以在用C参数,会覆盖之前的用户信息

查看认证文件的内容

# cat /usr/local/nagios/etc/htpasswd

f. 启动apache 服务

# /usr/local/apache2/bin/apachectl start

到这里nagios 的安装也就基本完成了,你可以通过web来访问了。


ubuntu下安装nagios的更多相关文章

  1. 在Ubuntu下安装ovs-dpdk

    在Ubuntu下安装ovs-dpdk 参考资料:https://software.intel.com/zh-cn/articles/using-open-vswitch-with-dpdk-on-ub ...

  2. Ubuntu 下安装QT

    Ubuntu 下安装QT 本文使用的环境 QT Library: qt-everywhere-opensource-src-4.7.4.tar.gz QT Creator: qt-creator-li ...

  3. Ubuntu下安装JDK以及相关配置

    1.查看系统位数,输入以下命令即可 getconf LONG_BIT 2.下载对应的JDK文件,我这里下载的是jdk-8u60-linux-64.tar.gz 3.创建目录作为JDK的安装目录,这里选 ...

  4. Ubuntu下安装mod_python报错(GIT错误)

    Ubuntu下安装mod_python3.4.1版本报出如下错误: writing byte-compilation script '/tmp/tmpE91VXZ.py' /usr/bin/pytho ...

  5. TODO:Ubuntu下安装Node

    TODO:Ubuntu下安装Node Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高 ...

  6. Ubuntu杂记——Ubuntu下安装VMware

    转战Ubuntu,不知道能坚持多久,但是自己还是要努力把转战过程中的学习到的给记录下来.这次就来记录一下,Ubuntu下如何安装VMware. 就我所知,Linux下有VirtualBox和VMwar ...

  7. 来杯Caffe——在ubuntu下安装Caffe框架并测试

    Caffe是一种深度学习框架...blablabla...... Caffe要在ubuntu下安装 1. 安装依赖 sudo apt-get install libatlas-base-dev sud ...

  8. Ubuntu 下安装 Mysql

    这里讲用Ubuntu下安装MySql ubuntu上安装mysql非常简单只需要几条命令就可以完成. 1. sudo apt-get install mysql-server   2. apt-get ...

  9. ubuntu下安装配置OpenCV

    Cmake的安装 我用的是ubuntu-software自动下载安装的. Ubuntu 下安装 OpenCV 首先下载安装相关包,然后下载OpenCV 系统:ubuntu16.04 OpenCV:2. ...

随机推荐

  1. Struts国际化

    第一步需要建立配置文件 格式为      文件名_zh_CN.properties    为中文配置文件   文件名_en_US.properties为美式英语配置文件 配置文件里面的值以键值对的形式 ...

  2. ubuntu 14.04 32位库

    如果是ubuntu 14.04,则请先执行: 方法1: sudo gedit /etc/apt/sources.list 然后在最后添加上: deb http://archive.ubuntu.com ...

  3. 客户端登录验证 -- ESFramework 4.0 快速上手(15)

    在之前版本的Rapid引擎中,是没有提供客户端登陆验证的机制的,如果要验证用户的帐号密码信息,我们只有自己手动通过自定义信息来实现.在2011.04.25发布的新版本中,客户端Rapid引擎,则内置了 ...

  4. angularjs表单

    <form ng-app="myApp" ng-controller="validateCtrl" name="myForm" nov ...

  5. python 函数/列表的应用

    enumerate 函数用于遍历序列中的元素以及它们的下标: >>> for i,j in enumerate(('a','b','c')): print i,j 0 a1 b2 c ...

  6. Openjudge-计算概论(A)-单词翻转

    描述: 输入一个句子(一行),将句子中的每一个单词翻转后输出. 输入只有一行,为一个字符串,不超过500个字符.单词之间以空格隔开.输出翻转每一个单词后的字符串,单词之间的空格需与原文一致. 样例输入 ...

  7. SharePoint2013基于Form(FBA)的AD认证登陆

    来源于:http://www.haogongju.net/art/1964313 1. 使用SharePoint2013实现基于AD的Form认证,首先创建一个Web Application,步骤如下 ...

  8. WPFbutton样式

    有四款button不同的风格 <Window x:Class="SjglzxRj.Window3" xmlns="http://schemas.microsoft. ...

  9. error while loading shared libraries: libseaudit.so.4: cannot open shared object file: Error 40

    安装共享库后要注意共享库路径设置问题, 如下: 1) 如果共享库文件安装到了/lib或/usr/lib目录下, 那么需执行一下ldconfig命令 ldconfig命令的用途, 主要是在默认搜寻目录( ...

  10. H5的新应用-指定视频的播放进度

    <!DOCTYPE html> <html> <head> <title>指定视频的播放进度</title> <meta http-e ...