Most Nagios Core servers are easier to maintain from distribution packages, but a source build is still useful when the monitoring host needs the current upstream release or the upstream /usr/local/nagios layout. The source installer compiles the daemon and CGI programs from a Nagios release tarball, then installs the sample configuration, web files, command directory, and startup integration.
This build path targets an Ubuntu or Debian family server with Apache as the web front end. It follows the upstream source targets and uses /etc/apache2/sites-enabled for the generated Apache configuration so the /nagios/ URL is available through the normal enabled-site path.
Nagios Plugins are separate from Nagios Core. A source-built Core install can pass the pre-flight check and load the web interface before plugins are installed, but the sample local checks need plugin commands under the path used by the command definitions before they can produce real monitoring results.
Related: How to install Nagios Core on Ubuntu
Related: How to install Nagios Core on Debian
Related: How to install Nagios plugins
Related: How to upgrade Nagios Core
$ sudo apt update
$ sudo apt install --assume-yes autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev openssl libssl-dev apache2-utils curl ca-certificates
The build uses GCC, make, GD headers, OpenSSL headers, Apache, PHP, htpasswd, and curl for the final HTTP check.
$ wget --output-document=/tmp/nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.5.13/nagios-4.5.13.tar.gz
Use the same release number in the download URL and extracted directory. Check the upstream release page before changing the version.
$ tar --extract --gzip --file /tmp/nagioscore.tar.gz --directory /tmp
$ cd /tmp/nagios-4.5.13
$ ./configure --with-httpd-conf=/etc/apache2/sites-enabled
$ make all
$ sudo make install-groups-users
$ sudo usermod --append --groups nagios www-data
On Ubuntu and Debian, Apache normally runs as www-data. Use the web server user from the target host if it differs.
$ sudo make install
$ sudo make install-daemoninit
Full systemd hosts receive the service integration used by nagios.service. Minimal containers may need a direct daemon start or an init script instead of systemctl.
$ sudo make install-commandmode
$ sudo make install-config
$ sudo make install-webconf
$ sudo a2enmod rewrite
$ sudo a2enmod cgi
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Use -c only for the first web user file. Running the command with -c again replaces existing Nagios web users.
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.5.13 ##### snipped ##### Reading configuration data... Read main config file okay... Read object config files okay... ##### snipped ##### Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
$ sudo apache2ctl configtest AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message Syntax OK
The AH00558 line is a hostname warning, not an install failure. Syntax OK confirms Apache can parse the generated Nagios web configuration.
$ sudo systemctl restart apache2.service
$ sudo systemctl enable --now nagios.service
On non-systemd hosts, use the startup method installed by make install-daemoninit, such as sudo /etc/init.d/nagios start.
Related: How to manage the Nagios Core system service
$ systemctl is-active nagios.service active
Use sudo /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg only for supervised or container test environments that do not run systemd.
$ sudo ufw allow Apache
Do not expose the Nagios web interface to untrusted networks before reviewing CGI authentication, authorization, and HTTPS.
$ curl --head --user nagiosadmin http://monitor.example.net/nagios/ Enter host password for user 'nagiosadmin': HTTP/1.1 200 OK Date: Mon, 22 Jun 2026 00:53:30 GMT Server: Apache/2.4.66 (Ubuntu) Content-Type: text/html; charset=UTF-8
Replace monitor.example.net with the monitoring server's DNS name or IP address. Source installs that follow the upstream web configuration use /nagios/ instead of the packaged /nagios4/ path.
http://monitor.example.net/nagios/
Log in as nagiosadmin with the password created by htpasswd. Open the Tactical Overview or Hosts page before adding remote hosts.
Source-built Nagios Core commonly expects plugins under /usr/local/nagios/libexec unless command definitions are changed.
Related: How to install Nagios plugins
Related: How to run a Nagios plugin manually