1. Create nagios users and user groups
[Root @ Centos ~] # Useradd-s/sbin/nologin nagios
[Root @ Centos ~] # Mkdir/usr/local/nagios
2. Prepare the installation environment
[Root @ Centos ~] # Yum install-yphp httpd gcc glibc-common gd-devel php-mysql-serverphp-snmp php-pdo perl-DBD-MYSQL php-pear openssl-devel
3. Downloading and installing nagios 4.0
[Root @ Centos ~] # Cd/usr/local/
[Root @ Centos ~] # Wgethttp: // response
[Root @ Centos ~] # Tar-zxvf nagios-4.0.0.tar.gz
[Root @ Centos ~] # Chown-Rnagios. nagios/usr/local/nagios
[Root @ Centos ~] # Cd nagios
[Root @ Centos ~] #./Configure -- prefix =/usr/local/nagios
[Root @ Centos ~] # Make all
[Root @ Centos ~] # Make install
Note :{
Make install is used to install the main program of nagios, CGI and HTML files
Run the make install-init command to create a nagios STARTUP script in the/etc/rc. d/init. d directory.
Make install-commandmode command to configure Directory Permissions
The make install-cofig command is used to install the nagios sample configuration file. The installation path is/usr/local/nagios/etc.
Make install-webconf is used to install the apache configuration file for the nagios web interface.
}
[Root @ Centos ~] # Make install-init
[Root @ Centos ~] # Make install-commandmode
[Root @ Centos ~] # Make install-cofig
[Root @ Centos ~] # Make install-webconf
4. Install the nagios plug-in
[Root @ Centos ~] # Wgethttp: // response
[Root @ Centos ~] # Tar-zxvf nagios-plugins-1.4.16.tar.gz
[Root @ Centos ~] # Cd nagios-plugins-1.4.16
[Root @ Centos ~] #./Configure -- prefix =/usr/local/nagios
[Root @ Centos ~] # Make all & make install
5. Configure httpd and php
Modify the httpd configuration file/etc/httpd/conf/httpd. conf
Find the following two rows:
User apache
Group apache
Change
User nagios
Group nagios
Then find
DirectoryIndex index.htmlindex.html. var
Change
DirectoryIndex index.htmlindex.html. var index. php
Add the following lines under it:
AddTypeapplication/x-httpd-php. php
Add the following information at the end of the configuration file:
# 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 "NagiosAccess"
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
Allowfrom all
AuthName "nagiosAccess"
AuthUserFile/usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
ServerName nagios: 80
Save configuration file
6. Configure the hosts file
Because I do not have an internal DNS server, I can only edit the hosts file
7. Start the httpd service
Service httpd start
8. Add a verification file
[Root @ Centos nagios] #/usr/bin/htpasswd-c/usr/local/nagios/etc/htpasswd Arthur
New password: (enter the password)
Re-type new password: (enter the password again)
Adding password for user Arthur
An htpasswd verification file is added under/usr/local/nagios/etc.
9. Add nagios to the startup service option.
Chkconfig -- level 35 nagioson
10. Start the nagios Service
/Etc/rc. d/init. d/nagios start or service nagios start
11. Disable SELINUX and IPTABLES
Setenforce 0
Service iptables stop
This is a temporary shutdown. It will be enabled again after restart!
12. Access nagios
Enter the nagios/nagios account in the browser, and then enter the new arthur account and password of the Account. The long-overdue page is displayed.
This article is from the "Xie haitang" blog, please be sure to keep this source http://xiehaitang.blog.51cto.com/4914337/1301145