第一步安装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. 2014web面试题

    面试题目会根据你的等级和职位变化,入门级到专家级:范围↑.深度↑.方向↑; 类型: 技术视野.项目细节.理论知识型题,算法题,开放性题,案例题. 进行追问,可以确保问到你开始不懂或者面试官开始不懂为止 ...

  2. Vultr免费vps注册和使用简易教程

    如果你是站长,寻找托管网站的主机,或者是开发者,需要搭建服务器环境,选购vps是必须的.强烈不推荐国内的vps产品,没有性价比,维护水平又烂,甚至某些国内所谓云主机vps安装后门,监控你的数据.海外v ...

  3. 【其他】MySql常用命令

    Linux下: 登陆命令 mysql -h [hostname] -u [username] -p [password]修改密码 mysqladmin –u[username] –p[oldpwd] ...

  4. 如何利用 MembershipUser 更改密码

    如何利用 MembershipUser 更改密码 作者: vkvi 来源:千一网络 (原创) 时间: 2009-3-11   完美集成.增强 KindEditor HTML 编辑器 在 ASP.NET ...

  5. Developing a Custom Membership Provider from the scratch, and using it in the FBA (Form Based Authentication) in SharePoint 2010

    //http://blog.sharedove.com/adisjugo/index.php/2011/01/05/writing-a-custom-membership-provider-and-u ...

  6. 【Machine Learning in Action --5】逻辑回归(LogisticRegression)从疝气病预测病马的死亡率

    背景:使用Logistic回归来预测患有疝气病的马的存活问题,这里的数据包括368个样本和28个特征,疝气病是描述马胃肠痛的术语,然而,这种病并不一定源自马的胃肠问题,其他问题也可能引发疝气病,该数据 ...

  7. angularJS 系列(七)---指令

    ----------------------------------------------------------------------------------- 原文:https://www.s ...

  8. APP生产流程图片解说

    尽我所能总结下一个app的生产过程,未必完整,也未必是所有的app产生的一个过程,不同公司会有很大的不同,我只是想总结下一般的大众的,做个参考. 需求策划: 设计: 开发: 测试: 发布没什么可画的了 ...

  9. MAC图片格式转换

    OS X下有一个sips的程序可以用来处理图片. sips的名称功能非常强大,参考 帮助文档 . 这里我们只用到其中的一个功能,转换图片格式. 命令参考: sips  - s format jpeg  ...

  10. Ip 讲解

    IP地址分类以及C类IP地址的子网划分 国际规定:把所有的IP地址划分为 A,B,C,D,E A类地址:范围从0-127,0是保留的并且表示所有IP地址,而127也是保留的地址,并且是用于测试环回用的 ...