Installing Nagios 3.5 on CentOS 6.5 Minimal

I’m in the middle of wrapping my head around a network I’ve inherited about one year ago. Honestly, I should have done this in the beginning but it’s better late than never.

Going into this network there was no monitoring in place. Nagios is a perfect tool for an environment with many services, links, servers, etc.

Here’s a little disclaimer: I’m not a Linux or Nagios guru. The following are from my own experiences and findings in my research. If you’d like to learn more about Nagios, I recommend reading Learning Nagios.

First, download CentOS Minimal and install it. I’m installing CentOS on VMware. Why CentOS Minimal? Because that’s all I need for this operating system, minimalism.

1. After you have CentOS installed, enable the eth0 interface

**Not familiar with vi? Here’s an external tutorial.**

vi /etc/sysconfig/network-scripts/ifcfg-eth0





Add the following to the configuration file, fill the X’s to your IP configuration:


Save the file and quit.

Now we need to restart the network service so this interface is enabled:

service network restart

2. This is about the time I connect to my virtual machine over ssh

Here are the packages we’ll have to install to complete the Nagios installation:

yum install httpd php gcc glibc glibc-common gd gd-devel openssl-devel wget perl make

We’re installing Apache, PHP, GNU Compiler Collection, Standard C Library, graphics library, OpenSSL, file retriever, Perl, and Make.

3. Create the nagios user and set the password

/usr/sbin/useradd -m nagios
passwd nagios

The -m switch says to create the home directory if it doesn’t exist.

4. Create the nagios group, nagcmd, which will allow external commands to be submitted through the web interface. Then add the nagios user and apache user to the group

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

The usermod switches, -a -G, says to append the user to the nagcmd group.

5. Create a temp directory to place the nagios downloads

mkdir ~/downloads
cd ~/downloads

Download nagios:

wget | wget

6. Extract the nagios tar ball

tar xzf nagios-3.5.0.tar.gz
cd nagios

7. Run the nagios script passing the nagcmd group

./configure --with-command-group=nagcmd

Take note of what gets spit out at the end. This is from my installation:

*** Configuration summary for nagios 3.5.0 03-15-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
             Mail program:  /bin/mail
                  Host OS:  linux-gnu

 Web Interface Options:
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/

8. Compile the nagios source code

make all

9. Install the binaries, init script, sample configs, and set permissions on external command directory

make install
make install-init
make install-config
make install-commandmode

Nagios is now installed but don’t start it yet.

10. The sample config files have been installed in the /usr/local/nagios/etc directory. Edit the /usr/local/nagios/etc/objects/contacts.cfg file and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

vi /usr/local/nagios/etc/objects/contacts.cfg

11. Configure the web interface

make install-webconf

12. Create the nagiosadmin account for logging into the web interface

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

13. Restart Apache

service httpd restart

14. Compile and install the plugins

cd ~/downloads
tar xzf nagios-plugin (tab) #press the tab key to complete the command
cd nagios-plugins (tab)

15. Compile and install the plugins

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

16. Add nagios to the system services and have it start when system boots

chkconfig --add nagios
chkconfig nagios on

17. Verify the nagios configuration files

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios. If there are errors, you have some troubleshooting to do!

service nagios start

18. Find out if you have SELinux in Enforced mode


If the value is on then you will need to follow step 19.

19. Most people will tell you to set the Enforce level to 0. This weakens the security of Linux. Instead, run the following commands to run the CGIs under SELinux enforcing/targeted mode

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

20. Log into the nagios web interface


21. If you try to access the web interface remotely and the page doesn’t load, check to see if you have IPTABLES enabled

service iptables status

If you don’t see entries for port 80 and/or 443, then it is being denied.

Allow http and https services through IPTABLES:

vi /etc/sysconfig/iptables

Add the following entries:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT


There are a couple of books if you want to get more in-depth with Nagios. I’ll admit that I am no where near being an expert on this topic. I am still learning myself.

Nagios: Building Enterprise-Grade Monitoring Infrastructures for Systems and Networks (2nd Edition) by David Josephsen

Nagios: System and Network Monitoring by Wolfgang Barth

Related Posts

About Rowell Dionicio

I am Rowell Dionicio, a network engineer with a coffee addiction, an advocate of WordPress, with a passion about networking and wireless. I am part of the Cisco Champion program and my purpose is to help you become a better engineer. Follow me on Twitter, LinkedIn, Facebook and YouTube.

  • Deepak S

    HI Rowell;

    I had installed nagios in my local system with the above steps. But while I am trying to execute “htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin” in my webserver it is showing an error “-bash: htpasswd: command not found”. can you please help me out in this request

    • Rowell Dionicio

      Hi Deepak,

      What if you use htpasswd2 instead of htpasswd?

  • Lukas

    Hey Rowell

    You’ve forgot:
    # chkconfig httpd on

    in my case, the Nagios service cant access the nagios.cmd in /nagios/var/rw
    -> # chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw

    Greetings from germany!


    • Rowell Dionicio

      Thanks Lukas!

  • manoj

    Hi Rowell,

    I have followed all above steps. Everthing was going to good. but when i am browsing below link, it’s showing 403 Forbidden error.

    Please suggest me.

    Manoj Gupta

    • Rowell Dionicio

      Hi Manoj, can you try putting this command in:

      chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw

  • Satish Aiwale

    great !!!

    • Rowell

      Thanks Satish!

  • Satish Aiwale


    I need help,

    Did you know, how to configure MRGT with Nagios.


  • prash

    after i followed the above steps. i am able to see only http page only instead of nagios.
    is there any changes needed on nagios.conf file(i means to say ip address entry OR host entry)etc.
    kindly suggest.

    Prash pUNE

  • Yuvaraj N

    All i can say is “It is 100 % perfect.!”. Thanks dude

    • Rowell

      I’m glad it worked for you!

  • Russ

    Awesome guide, worked first time without issue. Hats off to you sir :-)

    • Rowell

      Sweet! Glad it worked out for you.

  • Brian


    Great post it helped a lot. The only thing I did different was I saved the iptables at the end so when rebooting I didn’t have to add them again. Other than that worked great.


    • Rowell

      Glad it helped! It’s best to keep iptabes enabled. Great work!

  • selvakumar

    Thanks :)

    Please share NCONF, Nagios graph .. etc addional tool configuration page if u have

  • Satheesh

    Am installed nagios with the latest version, but getting the error ie “(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load, …) failed. errno is 2: No such file or directory” Can you help me for solving the same..???

    • charlie

      Did you figure this out? I’m getting the same error.

      • kulmeet

        i also have same issue whats the solution?

    • Nick


  • Srinivasan

    I got this output after make install “make[1]: Leaving directory `/opt/nagios'” can you give any suggestion to solve this

  • Lucas

    Very very Nice job!!

  • england

    this a great tut… thanks, it help me

  • TONY

    Very good Awesome guide, worked first time without any problem. Hats off to you buddy,…..very, very good job….Just got one question since I am new to nagios….can you tell me how I can go by configuring stuffs like service,contact.cfg,centreon etc or basically how I can get nagios to start monitoring and sending alerts…..
    Thanks once again you really made my job easier

  • Satatap

    whoa. this is great! shishishi. thanks!

  • Satatap

    Hi, I was able to install nagios without any error. Problem is when I go to map, “The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server.”
    Please, I need assistance. Thank you!

    • kulmeet

      that means module is missing in httpd.conf . load that module in httpd.cong


    Hi, Sometimes happening “(No output on stdout) stderr: ” and sometimes it will be automatically cleared. What is that probelm?
    How to fix it permanently. Please help me.

    • Rowell

      Looks like there’s a syntax error. When do you receive that error?

      • skvenkates

        Thank you for reply.
        Previously it (Nagios version 3.2.3) was worked fine. Then I un-installed Nagios version 3.2.3 and installed latest version 4.0.1. Sometimes showing currently. I couldn’t find when it is occurring.
        Please help me.

  • skvenkates

    Thank you for reply.
    Previously it (Nagios version 3.2.3) was worked fine. Then I un-installed Nagios version 3.2.3 and installed latest version 4.0.1. Sometimes showing currently. I couldn’t find when it is occurring.
    Please help me.

    • Rowell
      • skvenkates

        Yes… Have to change any settings?

        • Rowell

          If that bug describes your issue, then yes.

          • skvenkates

            Yes the same issue. I am seeing frequent service checks returning ‘(No output on stdout) stderr: ‘ in the Status Data field. The next check of the same service will return a normal response. After few checks then returning ‘(No output on stdout) stderr: ‘

          • skvenkates

            Hi Rowell, is there any solution?

          • Rowell

            Did you read the contents of the link? There was a fix in there.

  • Pratik Najare

    i m getting following error:-
    (No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_ping, …) failed. errno is 2: No such file or directory

    • Rowell

      Hi Pratik,

      Have you tried re-installing the plugins?

  • Dan

    Make sure you turn off SElinux if running centos. This will cause the errno is 2: No such file or directory.

    • Rowell

      Hey Dan,

      Thanks for chiming in. That’s useful information.

  • Jo

    What a great tutorial!! Everything just works fine without facing any issues! Thanks man!!