# pre-request to build nagios from source:
apt-get install autoconf gcc libc6 make apache2-utils libgd-dev
# get source from https://www.nagios.org/downloads/nagios-core/
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
tar xzf nagios-4.3.4.tar.gz
cd nagios-4.3.4/
./configure --with-httpd-conf=/etc/apache2/sites-enabled
# Output should look like this:
*** Configuration summary for nagios 4.3.4 2017-08-24 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/sites-enabled
Mail program: /usr/bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/sbin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
##################
# next we need to 'make' it ;-)
make all
# Output should look like this:
Enjoy.
# and we will in few minutes
# lets us create user for nagios
useradd nagios
# we will add him to apache group
usermod -a -G nagios www-data
# last but not least:
make install
# Output should look like this:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/archives
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/spool/checkresults
chmod g+s /usr/local/nagios/var/spool/checkresults
*** 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
##############
# let's add init script
make install-init
# and enable init script
systemctl enable nagios.service
# install and configure permissions for external command file:
make install-commandmode
# and add sample configuration so nagios will start:
make install-config
# add nagios-site apache configuration file:
make install-webconf
# we need to create nagiosadmin account for http
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# finally we can restart apache and start nagios:
systemctl restart apache2
systemctl start nagios
# open browser and type: nagios_ip_address/nagios/