mrbear 发表于 2019-1-15 06:06:05

Nagios安装流程(centos 5.5环境 + nagios

  Nagios安装流程(centos 5.5环境 + nagios-cn-3.2.3.tar.bz2+ )
1、更新yum源
2、安装组件
# yum -y install httpd gettext mysql mysql-server mysql-devel php php-mysql php-pear
# yum -y install gd gd-devel php-gd
安装nagios时需要加--with-gd-lib=/usr/lib --with-gd-inc=/usr/include   
不然不能生成statusmap.cgi也就不能看状态图了!
3、增加帐号
# useradd nagios
# passwd nagios
nagios
# usermod -s /sbin/nologin nagios
# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache
4、解压nagios-cn文件
# tar -jxvf nagios-cn-3.2.3.tar.bz2
5、进入解压文件夹
#cd nagios-cn-3.2.3
6、 运行安装命令
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
备注:提示错误
file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.png
解决办法:因为是centos linux,默认可以采用yum方式安装,则采用如下命令安装gcc编译器即可:# yum -y install gcc
7、再次运行安装命令(第6步命令),提示没有错误后运行make all 命令然后依次执行下面的命令
#make all install
#make install-init   //安装启动脚本到/etc/init.d
#make install-commandmode
#make install-config//安装初始配置文件到/usr/local/nagios
8、退出nagios文件夹并解压nagios-plugins并进入
#cd ..
# tar -zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
9、执行安装命令
#./configure --prefix=/usr/local/nagios-plugins --with-nagios-user=nagios --with-nagios-group=nagios
10、            然后执行以下命令
# make
# make install
11、            安装完成以后在/usr/local/nagios-plugins 会产生一个 libexec 的目录,将该目录全部移动到/usr/local/nagios目录下即可。
#mv /usr/local/nagios-plugins/libexec /usr/local/nagios/
12、            配置Apache:在apache的httpd.conf 文件中加入如下内容:
# vi /etc/httpd/conf/httpd.conf
###nagios
ScriptAlias /nagios/cgi-bin "/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


Alias /nagios "/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

13、            启动Apache服务
# service httpd restart
14、            设置报报警邮箱
# vi /usr/local/nagios/etc/objects/contacts.cfg
将nagios@localhost改为自己的邮箱(310475629@qq.com),保存并退出。
15、            设置登陆web密码
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: (nagiosadmin)
Re-type new password: (nagiosadmin)
Adding password for user nagiosadmin
16、            启动(重启)相关服务(Apache及nagios服务)
# service httpd restart
# service nagios restart

17、            检查配置文件是否正确
如果出现如下显示就说明配置没问题
Total Warnings: 0
Total Errors:   0
18、            现在就可以http://你的 IP/nagios/访问 nagios(实验IP地址为192.168.1.8),提示正常的界面则nagios安装成功。



页: [1]
查看完整版本: Nagios安装流程(centos 5.5环境 + nagios