Deploy Nagios based on Nginx environment

Source: Internet
Author: User
Tags stop script perl script

Installation ideas, for reference only

# # #nagios安装

Yum Install Gd-devel-y

Useradd Nagios

Groupadd Nagcmd

Usermod-a-G Nagcmd Nagios

Usermod-a-G Nagcmd www

Tar xzf nagios-3.5.0.tar.gz

CD Nagios

./configure--with-group=nagios--with-user=nagios--with-command-group=nagcmd--prefix=/usr/local/nagios

Make all

Make install #用于安装主要的程序, CGI, and HTML files

Make Install-init #用于生成init启动脚本

Make Install-config #用于安装示例配置文件

Make Install-commandmode #用于设置相应的目录权限

Set the Nagios Web login account password

Htpasswd-c/usr/local/nagios/etc/nagiospasswd Nagiosadmin

New Password:

Re-type New Password:

[Adding Password for user Nagios

Give Nagios users permission to view information! [Webmaster's name is the user in your htpasswd.users]

Vim/usr/local/nagios/etc/cgi.cfg

Add Nagios after all nagiosadmin multiple users are separated by commas or replaced directly with Nagios

]

# # # #安装插件

Tar zxf nagios-plugins-2.0.3.tar.gz

CD nagios-plugins-2.0.3

./configure--with-nagios-user=nagios--with-nagios-group=nagios--prefix=/usr/local/nagios/

Make

Make install

#########

Installing the FCGI module

wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz

TAR-ZXVF fcgi-0.67.tar.gz

CD FCGI-0.67

Perl makefile.pl

Make && make install

Install Fcgi-procmanager:

wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz

TAR-XZXF fcgi-procmanager-0.18.tar.gz

CD fcgi-procmanager-0.18

Perl makefile.pl

Make && make install

Installing the IO and Io::all modules

wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz

Tar zxvf io-1.25.tar.gz

CD IO-1.25

Perl makefile.pl

Make

Make install

Cd..

wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.41.tar.gz

Tar zxvf io-all-0.41.tar.gz

CD io-all-0.41

Perl makefile.pl

Make

Make install

Cd..

############################################################################################################### #

Configuration of Nginx

######### #安装nginx

Yum install gcc openssl-devel pcre-devel zlib-devel-y

Useradd-s/sbin/nologin

Useradd-s/sbin/nologin www

Tar zixf nginx-1.5.1.tar.gz

CD nginx-1.5.1

./configure--prefix=/usr/local/nginx

Make && make install

Install PHP

PHP-5.4.11.TAR.BZ2 php-5.2.9-fpm-0.5.10-unofficial.diff.gz

Tar fvxj php-5.4.11.tar.bz2

GZIP-CD php-5.2.9-fpm-0.5.10-unofficial.diff.gz | Patch-d PHP-5.4.11-P1

./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--disable-fileinfo (when memory is less than 1G plus this will cause an error, If the prompt does not recognize fstcgi, no impact on the high version comes with this module does not need to be added)

Make

Make install

CP Php.ini-production/usr/local/php/lib/php.ini

Modify profile User name user group (same as Nginx user, Group)

The default configuration file for PHP-FPM is/usr/local/php/etc/php-fpm.conf

User www

Group www

Start

/usr/local/php/sbin/php-fpm

Download perl script for Perl fast-cgi interface, let Nginx process Perl in CGI, modify permission to 755

wget Http://www.mike.org.cn/wp-content/uploads/2011/07/perl-fcgi.zip

Unzip and copy to Nginx directory (recommended)

CP perl-fcgi.pl/usr/local/nginx/

Chown 755/usr/local/nginx/perl-fcgi.pl

chmod +x/usr/local/nginx/perl-fcgi.pl

Create a CGI start/stop script to manage the above script, user identity is WWW, need to modify according to their actual users, modify permissions 755

vim/usr/local/nginx/conf/start_perl_cgi.sh

######################################

#!/bin/bash

#set-X

#此处需要根据实际情况进行修改

Dir=/usr/local/nginx

Stop ()

{

#pkill-F $dir/perl-fcgi.pl

Kill $ (Cat $dir/logs/perl-fcgi.pid)

RM $dir/logs/perl-fcgi.pid 2>/dev/null

RM $dir/logs/perl-fcgi.sock 2>/dev/null

echo "Stop perl-fcgi Done"

}

Start ()

{

RM $dir/now_start_perl_fcgi.sh 2>/dev/null

Chown www.www $dir/logs

echo "$dir/perl-fcgi.pl-l $dir/logs/perl-fcgi.log-pid $dir/logs/perl-fcgi.pid-s $dir/logs/perl-fcgi.sock" >>$ dir/now_start_perl_fcgi.sh

Chown www.www $dir/now_start_perl_fcgi.sh

chmod u+x $dir/now_start_perl_fcgi.sh

Sudo-u www $dir/now_start_perl_fcgi.sh

echo "Start perl-fcgi Done"

}

Case $ in

Stop

Stop

;;

Start

Start

;;

Restart

Stop

Start

;;

Esac

Start Perl

/usr/local/nginx/conf/start_perl_cgi.sh start

#########################################

Nginx configuration file

VI nginx.conf

User www www;

Events {

Worker_connections 1024;

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Sendfile on;

Keepalive_timeout 65;

Server

{

Listen 80;

Index index.html index.htm index.php;

Root/usr/local/nagios/share;

Auth_basic "Nagios Access";

AUTH_BASIC_USER_FILE/USR/LOCAL/NAGIOS/ETC/NAGIOSPASSWD;

Location ~. *\. (PHP|PHP5)? $

{

;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Include fastcgi.conf;

}

Location ~. *\. (CGI|PL)? $

{

gzip off;

Root/usr/local/nagios/sbin;

Rewrite ^/nagios/cgi-bin/(. *) \.cgi/$1.cgi break;

Fastcgi_pass Unix:/usr/local/nginx/logs/perl-fcgi.sock;

Fastcgi_param Script_filename/usr/local/nagios/sbin$fastcgi_script_name;

Fastcgi_index index.cgi;

Fastcgi_read_timeout 60;

Fastcgi_param Remote_user $remote _user;

Include fastcgi.conf;

Auth_basic "Nagios Access";

AUTH_BASIC_USER_FILE/USR/LOCAL/NAGIOS/ETC/NAGIOSPASSWD;

}

Location/nagios

{

Alias/usr/local/nagios/share;

Auth_basic "Nagios Access";

AUTH_BASIC_USER_FILE/USR/LOCAL/NAGIOS/ETC/NAGIOSPASSWD;

}

Access_log/data1/logs/access_www.log Wwwlogs;

}

}

If you encounter an error, check Error.log


This article is from the "Ops 20 year" blog, please make sure to keep this source http://huangqingwu.blog.51cto.com/9592044/1674902

Deploy Nagios based on Nginx environment

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.