部署lap環境php
Centos7安裝epel源:html
1 rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
[root@juny-10 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm前端
1 yum clean all && yum list
安裝所須要的依賴linux
1 yum install gcc glibc glibc-common php gd gd-devel libpng libmng libjeg zlib -y
已安裝:ios
gd-devel.x86_64 0:2.0.35-26.el7 libmng.x86_64 0:1.0.10-14.el7 php.x86_64 0:5.4.16-42.el7 web
做爲依賴被安裝:apache
expat-devel.x86_64 0:2.1.0-10.el7_3 fontconfig-devel.x86_64 0:2.10.95-11.el7 vim
freetype-devel.x86_64 0:2.4.11-15.el7 httpd.x86_64 0:2.4.6-67.el7.centos.6 windows
httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 libX11-devel.x86_64 0:1.6.5-1.el7 centos
libXau-devel.x86_64 0:1.0.8-2.1.el7 libXpm-devel.x86_64 0:3.5.12-1.el7
libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 libpng-devel.x86_64 2:1.5.13-7.el7_2
libxcb-devel.x86_64 0:1.12-1.el7 libzip.x86_64 0:0.10.1-8.el7
mailcap.noarch 0:2.1.41-2.el7 php-cli.x86_64 0:5.4.16-42.el7
php-common.x86_64 0:5.4.16-42.el7 xorg-x11-proto-devel.noarch 0:7.7-20.el7
zlib-devel.x86_64 0:1.2.7-17.el7
安裝httpd 而後啓動
1 yum install httpd -y
啓動httpd
1 systemctl start httpd
新建nagios用戶
1 useradd nagios
新建一個運行組
1 groupadd nagcmd
把用戶和Apache加到新建的組裏面去
1 usermod -G nagcmd nagios
1 usermod -G nagcmd apache
新建一個Nagios文件夾
把須要用到的安裝包放到文件夾裏面
1 mkdir Nagios
1 cd Nagios/
[root@juny-10 Nagios]# ls
nagios-3.5.1.tar.gz nagios-plugins-2.1.1.tar.gz nrpe-2.15.tar.gz vautour_style.zip
[root@juny-10 Nagios]#
解壓併到nagios目錄下
1 tar xvf nagios-3.5.1.tar.gz -C /usr/local/src/ ; cd /usr/local/src/nagios
指定組進行編譯
[root@juny-10 nagios]# ./configure --with-command-group=nagcmd
*** Configuration summary for nagios 3.5.1 08-30-2013 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios #運行用戶
Command user/group: nagios,nagcmd #運行用戶組
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 #Apache的conf.d配置文件目錄
Mail program: /usr/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): /usr/bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
[root@juny-10 nagios]# 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-init
- This installs the init script in /etc/rc.d/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
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation #主題相關的,不須要安裝
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui #主題相關的,不須要安裝
- This installs the classic theme for the Nagios
web interface
*** 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.
[root@juny-10 nagios]#
[root@juny-10 nagios]# make install
#安裝生成/usr/local/nagios/,其中/usr/local/nagios/share即nagiosWEB訪問界面的站點目錄
[root@juny-10 nagios]# make install-init
#安裝生成/etc/rc.d/init.d/nagios 啓動腳本
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
*** Init script installed ***
[root@juny-10 nagios]# make install-commandmode
#設定相應nagios工做目錄的權限
/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 ***
[root@juny-10 nagios]# make install-config
#安裝生成/usr/local/nagios/etc下的nagios相關配置文件
*** 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.
[root@juny-10 nagios]#
[root@juny-10 nagios]# make install-webconf
#安裝Nagios的WEB配置文件到Apache的conf.d目錄下
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
*** Nagios/Apache conf file installed ***
到此安裝就結束了
在安裝的時候,make install生成share這個目錄,這個目錄是訪問界面目錄:
[root@juny-10 nagios]# ls /usr/local/nagios/share/
config.inc.php docs includes js media rss-corefeed.php side.php stylesheets
contexthelp images index.php main.php robots.txt rss-newsfeed.php ssi
在make install-init的時候,生成啓動腳本
[root@juny-10 nagios]# ls /etc/init.d/nagios
/etc/init.d/nagios
在make install-config的時候,生成了Nagios的相關配置文件;包括之後安裝了plugin等軟件後,配置文件也會放入此目錄
resource.cfg:定義了不少資源變量的調用
[root@juny-10 nagios]# ls /usr/local/nagios/etc/
cgi.cfg nagios.cfg objects resource.cfg
在make install-webconf的時候,已經把web-conf的配置文件放入了/etc/httpd/conf.d/下面
[root@juny-10 nagios]# ls /etc/httpd/conf.d/nagios.conf
/etc/httpd/conf.d/nagios.conf #裏面配置了一個別名,直接引用了/usr/local/nagios/share目錄
[root@juny-10 nagios]# vim /etc/httpd/conf.d/nagios.conf
能夠看到別名和路徑
[root@juny-10 nagios]# ll /usr/local/nagios/
總用量 0
drwxrwxr-x 2 nagios nagios 38 11月 6 01:01 bin #nagios執行程序的所在目錄
drwxrwxr-x 3 nagios nagios 74 11月 6 01:04 etc #nagios配置文件目錄;初安裝時只有幾個配置文件
drwxrwxr-x 2 nagios nagios 6 11月 6 01:01 libexec #監控所用命令、須要安裝nagios-plugins插件纔會有;不是空的
drwxrwxr-x 2 nagios nagios 311 11月 6 01:01 sbin #nagios的cgi文件所在目錄,外部命令所須要的文件存放目錄
drwxrwxr-x 10 nagios nagios 257 11月 6 01:01 share #nagios前端頁面
drwxrwxr-x 5 nagios nagios 45 11月 6 01:03 var #日誌文件
[root@juny-10 nagios]#
認識nagios配置文件
[root@juny-10 nagios]# vim /usr/local/nagios/etc/nagios.cfg
log_file=/var/log/nagios/nagios.log #日誌位置
cfg_file=/etc/nagios/objects/commands.cfg #這個文件定義了不少命令
cfg_file=/etc/nagios/objects/contacts.cfg #定義聯繫人,怎麼聯繫
cfg_file=/etc/nagios/objects/timeperiods.cfg #定義了時間段
cfg_file=/etc/nagios/objects/templates.cfg #模板(聯繫人,主機,時間)
cfg_file=/etc/nagios/objects/localhost.cfg #監控本機相關配置文件
#cfg_file=/etc/nagios/objects/windows.cfg #windows,默認不監控
#cfg_file=/etc/nagios/objects/switch.cfg #交換機路由器監控,默認不監控
#cfg_file=/etc/nagios/objects/printer.cfg #打印機監控,默認不監控
#cfg_dir=/etc/nagios/servers #定義了服務合集(多個使用)
#cfg_dir=/etc/nagios/printers #定義了打印機合集(多個使用)
#cfg_dir=/etc/nagios/switches #定義了交換合集(多個使用)
#cfg_dir=/etc/nagios/routers #定義了路由合集(多個使用)
resource_file=/etc/nagios/private/resource.cfg 資源變量配置文件,包括$USER1$變量(一個路徑)等
status_update_interval=10 #狀態更新時間,單位s
log_rotation_method=d #日誌滾動,默認天
service_check_timeout=60 #服務檢查超時時間
host_check_timeout=30 #主機檢查超時時間
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
認識下cgi文件
[root@juny-10 nagios]# vim /usr/local/nagios/etc/cgi.cfg
main_config_file= /usr/local/nagios/etc/nagios.cfg #主配置文件
physical_html_path= /usr/local/nagios/share #物理路徑
url_html_path=/nagios #在URL後面加上/nagios才能訪問
use_authentication=1 #使用認證
use_ssl_authentication=0 #不使用ssl
authorized_for_system_information=nagiosadmin #認證用戶
重啓Apache服務
[root@juny-10 nagios]# systemctl restart httpd
在瀏覽器輸入ip/nagios
能夠看到須要用戶名和密碼
查看用戶名和密碼
[root@juny-10 nagios]# vim /etc/httpd/conf.d/nagios.conf
在Directory字段裏面有Auth這三個字段,那麼就能夠使用htpasswd來生成用戶名和密碼
[root@juny-10 nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 123456
Re-type new password: 123456
Adding password for user nagiosadmin
# -c表示建立,二次添加用戶,不能使用-c參數
檢查配置文件
在nagios的目錄下,bin目錄下有一個nagios命令,這個命令能夠幫助咱們對配置文件的檢查工做以及指定相關配置文件
[root@juny-10 nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL
Total Warnings: 0 #警告
Total Errors: 0 #錯誤
Things look okay - No serious problems were detected during the pre-flight check
[root@juny-10 nagios]#
重啓Apache再次測試
[root@juny-10 nagios]# systemctl restart httpd
登陸成功
可是如今尚未作任何深刻配置,因此如今只是能夠登陸而已!