Nagios platform migrating from Apache to Nginx

Source: Internet
Author: User

Nginx's performance is far superior to Apache, but because Nagios's web interface contains PHP and C-CGI programs, it requires two sets of fcgi management tools (not required) and two sets of interpreters (must). PHP with php-cgi Run can, c-cgi I choose Fcgiwrap. The installation/configuration steps are described below.


php-fpm: A fastcgi management patch for PHP that can smoothly change php.ini configuration without restarting php-cgi
spawn-fcgi: is a branch project of LIGHTTPD, a manager of a CGI process

PHP hits PHP-FPM patches,--enable-fastcgi--enable-fpm parameters are enabled at compile time, PHP-FPM management php-cgi is used. PHP installation Detailed steps see Zhang Yi article: http://blog.s135.com/nginx_php_v5/
C-CGI uses spawn-fcgi management, using Fcgiwrap drivers. Fcgiwrap Introduction See Http://nginx.localdomain.pl/wiki/FcgiWrap

php-cgi Monitor 127.0.0.1:9000
Fcgiwrap Monitor 127.0.0.1:10000

Nagios installation configuration is not the focus of this article, skip. The Web directory is as follows:
/usr/local/nagios/share

Installing spawn-fcgi

wget Http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-1.6.3.tar.gztar XF spawn-fcgi-1.6.3.tar.gzcd/usr/local/src/spawn-fcgi-1.6.3./configure--prefix=/usr/local/spawn-fcgimake & & Make Install

Installing the FCGI Library

wget Http://dl.fedoraproject.org/pub/epel/6/x86_64/fcgi-2.4.0-10.el6.x86_64.rpmwget http://dl.fedoraproject.org/ PUB/EPEL/6/X86_64/FCGI-DEVEL-2.4.0-10.EL6.X86_64.RPMRPM-IVH FCGI-2.4.0-10.EL6.X86_64.RPMRPM-IVH fcgi-devel-2.4.0-10.el6.x86_64.rpm

Note : the above fcgi software rpm for RHEL6 corresponding version, if is 5 series please install RHEL5 corresponding version of the FCGI Library, RHEL5 software as follows:

fcgi:http://flexbox.sourceforge.net/centos/5/x86_64/fcgi-2.4.0-10.el5.x86_64.rpm

fcgi-devel:http://flexbox.sourceforge.net/centos/5/x86_64/fcgi-devel-2.4.0-10.el5.x86_64.rpm

Installing Fcgiwrap

Fcgiwrap Wiki--Http://nginx.localdomain.pl/wiki/FcgiWrap

The latest version is gnosek-fcgiwrap-1.1.0-0-g333ff99.tar.gz

CD gnosek-fcgiwrap-333ff99/autoreconf-i./configure--prefix=/usr/local/fcgiwrapmake && make install

Create a shell script to start the Fcgiwrap instance with spawn-fcgi

Vi/usr/local/bin/c-fcgi.sh#!/bin/sh/usr/local/spawn-fcgi/bin/spawn-fcgi-f/usr/local/fcgiwrap/bin/fcgiwrap-a 127.0.0.1-p 10000-f 3-p/var/run/fastcgi-c.pid-u daemon-g daemonchmod +x/usr/local/bin/c-fcgi.sh

The parameters have the following meanings:

-F <fcgiapp> Specifies the execution program location of the process calling FastCGI

-A <addr> bind to address addr

-P <port> bind to ports port

-S <path> path bound to Unixsocket

-C < children> Specifies the number of processes generated for fastcgi (PHP only)

-F <children> Specifies the number of processes generated by the fastcgi

-P <path> Specify PID file path for the resulting process

What identity is used by-u and-G fastcgi (-u user-G user group), which runs with Nginx user and group daemon


Create a system boot process that facilitates the use of service and chkconfig command tubes

vi /etc/init.d/c-fcgi#!/bin/bash# c-fcgi - this  script starts and stops the fcgiwrap instance## chkconfig:    - 96 28# description:  c-fcgi# processname: c-fcgic_script=/usr /local/bin/c-fcgi.shretval=0case  "$"  instart) echo  "starting fastcgi" $C _scriptretval=$?; Stop) echo  "stopping fastcgi" killall -9 fcgiwrapretval=$?;; Restart) echo  "restarting fastcgi" killall -9 fcgiwrap$c_scriptretval=$?;; *) echo  "Usage: c-fastcgi {start|stop|restart}" exit 1;; esacexit  $RETVAL # <span style= "color:  #0000ff;" >chkconfig --add c-fcgi</span># <span style= "color:  #0000ff;" >chkconfig c-fcgi on</span># <span style= "color:  #0000ff;" >service c-fcgi start</span> 

Verify that the appropriate port

is available for startup

#netstat  -tulnpActive Internet connections  (only servers) proto recv-q  send-q local address                Foreign Address              state       pid/program nametcp         0      0 127.0.0.1:9000               0.0.0.0:*                    LISTEN       32629/php-cgitcp        0      0  127.0.0.1:10000             0.0.0.0:*                    listen       20039/fcgiwrap
 #ps  -ef | grep fcgiwrap | grep -v  grepdaemon      20039     1  0  15:20 ?        00:00:00 /usr/local/bin/fcgiwrapdaemon       20040     1  0 15:20 ?         00:00:00 /usr/local/bin/fcgiwrapdaemon       20041     1  0 15:20 ?       &NBSP;&NBSP;00:00:00&NBSP;/USR/LOCAL/BIN/FCGIWR 
#ps  -ef | grep php-cgi | grep -v grepnginx     22046     1  0 jul10 ?         00:00:00 /usr/bin/php-cginginx    22047 22046  0 jul10  ?        00:00:00 /usr/bin/php-cginginx     22048 22046  0 jul10 ?        00:00:00  /usr/bin/php-cginginx    22049 22046  0 Jul10 ?         00:00:00 /usr/bin/php-cginginx    22050  22046  0 jul10 ?        00:00:00 /usr/bin/ php-cginginx    22051 22046  0 jul10 ?         00:00:00 /usr/bin/php-cgi 
configuring Nginx-related Nagios settings
server {        listen 80;         server_name nagios.icoffer.cn;        root  /usr/local/nagios/share;        index index.php;         auth_basic       "welcome to  Jobkoo nagios monitor system! ";         auth_basic_user_file    ./htpasswd;                 location / nagios{        alias /usr/local/nagios/share/;         }        location ~ .*\.cgi?$  {        root /usr/local/nagios/sbin;        rewrite ^/nagios/cgi-bin/(. *) \.cgi /$1.cgi break;         fastcgi_pass  127.0.0.1:10000;         fastcgi_index index.cgi;        fastcgi_ param   script_filename   $document _root$fastcgi_script_name;         include         fastcgi_params;         }        location ~  \.php$ {        fastcgi_pass    127.0.0.1:9000;        fastcgi_index  index.php;         fastcgi_param  SCRIPT_FILENAME  $document _root$fastcgi_ script_name;        fastcgi_read_timeout 500;        include         fastcgi_params;         fastcgi_buffers 8 128k;        }}

Configuring Nagios Nginxweb Authentication

Htpasswd-c/etc/nginx/conf.d/htpasswd ADMINCAT/ETC/NGINX/CONF.D/HTPASSWDADMIN:QQBXSY3JDKOPQ

If you do not have the HTPASSWD command, install the Httpd-tools package

Nagios platform migrating from Apache to Nginx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.