Nginx+nagios安装配置

[root@Nagios ~]# vi /etc/nginx/nginx.conf

    server {
listen ;
server_name localhost;
auth_basic "Nagios Access";
auth_basic_user_file /usr/local/nagios/passwd;
location / {
root /usr/local/nagios/share;
index index.html index.htm index.php;
} location ~ .*\.(php|php5)?$ {
root /usr/local/nagios/share;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
} location /nagios {
alias /usr/local/nagios/share;
} location /cgi-bin/images {
alias /usr/local/nagios/share/images;
} location /cgi-bin/stylesheets {
alias /usr/local/nagios/share/stylesheets;
} location /cgi-bin {
alias /usr/local/nagios/sbin;
} location ~ .*\.(cgi|pl)?$ {
gzip off;
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$.cgi break;
fastcgi_pass unix:/var/run/perl-fastcgi.sock;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
fastcgi_index index.cgi;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param HTTP_ACCEPT_LANGUAGE en_US;
include fastcgi_params;
fastcgi_read_timeout ;
} location /nagiosql/ {
alias /usr/local/nagios/nagiosql;
}
} [root@Nagios ~]# echo -en 'nagios:'>/usr/local/nagios/share/passwd
[root@Nagios ~]# perl -e 'print crypt($ARGV[0], "nagios")' passwd >>/usr/local/nagios/share/passwd
# 安装 PHP php-fpm
[root@Nagios ~]# yum install -y php php-fpm
[root@Nagios ~]# /etc/init.d/php-fpm start
# 安装perl FCGI
[root@Nagios ~]# yum install -y perl-devel
[root@Nagios src]# wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.74.tar.gz
[root@Nagios src]# tar zxf FCGI-0.74.tar.gz
[root@Nagios src]# cd FCGI-0.74
[root@Nagios FCGI-0.74]# perl Makefile.PL
[root@Nagios FCGI-0.74]# make && make install [root@Nagios ~]# touch /usr/bin/fastcgi-wrapper.pl
[root@Nagios ~]# chmod /usr/bin/fastcgi-wrapper.pl
[root@Nagios ~]# vi /usr/bin/fastcgi-wrapper.pl
#!/usr/bin/perl use FCGI;
use Socket;
use POSIX qw(setsid); require 'syscall.ph'; &daemonize; #this keeps the program alive or something after exec'ing perl scripts
END() { } BEGIN() { }
*CORE::GLOBAL::exit = sub { die "fakeexit\nrc=".shift()."\n"; };
eval q{exit};
if ($@) {
exit unless $@ =~ /^fakeexit/;
}; &main; sub daemonize() {
chdir '/' or die "Can't chdir to /: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask ;
} sub main {
#$socket = FCGI::OpenSocket( "127.0.0.1:8999", ); #use IP sockets
$socket = FCGI::OpenSocket( "/var/run/perl-fastcgi.sock", );
$request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params, $socket );
if ($request) { request_loop()};
FCGI::CloseSocket( $socket );
} sub request_loop {
while( $request->Accept() >= ) { #processing any STDIN input from WebServer (for CGI-POST actions)
$stdin_passthrough ='';
$req_len = + $req_params{'CONTENT_LENGTH'};
if (($req_params{'REQUEST_METHOD'} eq 'POST') && ($req_len != ) ){
my $bytes_read = ;
while ($bytes_read < $req_len) {
my $data = '';
my $bytes = read(STDIN, $data, ($req_len - $bytes_read));
last if ($bytes == || !defined($bytes));
$stdin_passthrough .= $data;
$bytes_read += $bytes;
}
} #running the cgi app
if ( (-x $req_params{SCRIPT_FILENAME}) && #can I execute this?
(-s $req_params{SCRIPT_FILENAME}) && #Is this file empty?
(-r $req_params{SCRIPT_FILENAME}) #can I read this file?
){
pipe(CHILD_RD, PARENT_WR);
my $pid = open(KID_TO_READ, "-|");
unless(defined($pid)) {
print("Content-type: text/plain\r\n\r\n");
print "Error: CGI app returned no output - ";
print "Executing $req_params{SCRIPT_FILENAME} failed !\n";
next;
}
if ($pid > ) {
close(CHILD_RD);
print PARENT_WR $stdin_passthrough;
close(PARENT_WR); while(my $s = <KID_TO_READ>) { print $s; }
close KID_TO_READ;
waitpid($pid, );
} else {
foreach $key ( keys %req_params){
$ENV{$key} = $req_params{$key};
}
# cd to the script's local directory
if ($req_params{SCRIPT_FILENAME} =~ /^(.*)\/[^\/]+$/) {
chdir $;
} close(PARENT_WR);
close(STDIN);
#fcntl(CHILD_RD, F_DUPFD, );
syscall(&SYS_dup2, fileno(CHILD_RD), );
#open(STDIN, "<&CHILD_RD");
exec($req_params{SCRIPT_FILENAME});
die("exec failed");
}
}
else {
print("Content-type: text/plain\r\n\r\n");
print "Error: No such CGI app - $req_params{SCRIPT_FILENAME} may not ";
print "exist or is not executable by this process.\n";
} }
} [root@Nagios ~]# touch /etc/init.d/perl-fastcgi
[root@Nagios ~]# chmod /etc/init.d/perl-fastcgi
[root@Nagios ~]# vi /etc/init.d/perl-fastcgi
#!/bin/sh
#
# nginx – this script starts and stops the nginx daemon
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/logs/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit perlfastcgi="/usr/bin/fastcgi-wrapper.pl"
prog=$(basename perl) lockfile=/var/lock/subsys/perl-fastcgi start() {
[ -x $perlfastcgi ] || exit
echo -n $"Starting $prog: "
daemon $perlfastcgi
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
stop
start
} reload() {
echo -n $”Reloading $prog: ”
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
}
rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit
esac

nagios安装请参考该篇:http://www.cnblogs.com/caoguo/p/4981903.html

Nginx+nagios安装配置的更多相关文章

  1. nginx初级安装配置

    nginx初级安装配置 转自:(lykyl原创)http://www.cnblogs.com/lykyl/archive/2012/11/21/2781077.html 实验环境:系统 CENTOS5 ...

  2. nginx+tomcat安装配置

    nginx+tomcat安装配置 # nginx+tomcat安装配置 #创建网站目录 mkdir -p /www/wwwroot cd /www #安装配置 wget http://mirrors. ...

  3. gerrit+nginx+centos安装配置

    安装环境 centos 6.8 gerrit-full-2.5.2.war 下载地址:https://gerrit-releases.storage.googleapis.com/gerrit-ful ...

  4. Nginx的安装配置和tomcat负载均衡

    Nginx简介 什么是nginx? Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.由俄罗斯的程序设计师Igor Sysoev所开发,官方测试ngi ...

  5. nginx php-fpm安装配置 CentOS编译安装php7.2

    CentOS编译安装php7.2 介绍: 久闻php7的速度以及性能那可是比php5系列的任何一版本都要快,具体性能有多好,建议还是先尝试下再说.如果你是升级或新安装,那你首先需要考虑php7和程序是 ...

  6. 吴裕雄--天生自然Django框架开发笔记:Django Nginx+uwsgi 安装配置

    Django Nginx+uwsgi 安装配置 使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,需要一个可以稳定而持续的服务器,比如 ...

  7. centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置

    前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...

  8. Nginx服务安装配置

    1.Nginx介绍 Nginx是一个高性能的HTTP和反向代理服务器,由俄罗斯人开发的,第一个版本发布于2004年10月4日.Nginx由于出色的性能,在世界范围内受到了越来越多人的关注,其特点是占有 ...

  9. Django Nginx+uwsgi 安装配置

    使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache, Nginx, lighttp ...

随机推荐

  1. 武大OJ 612. Catch the sheep

    Description Old Sama is a great and powerful magician in the word. One day, a little girl, Anny, tou ...

  2. Mybatis错误——Could not find parameter map java.util.Map

    错误信息 org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map java.util.Ma ...

  3. webpack打包的基础原理-打包后的文件解读

    1.概念 本质上,webpack 基于node平台,利用 node 的各种api来实现 javascript 应用程序的一个静态模块的打包工具. 在打包过程中,构建依赖关系,并且实现模块引用预处理,以 ...

  4. 使用深度双向LSTM模型构造社区问答系统

    所看到的. 首先强调一下,这个结构也是一个解决对照两个句子类似性的通用RNN解决方式,不只能够使用在问答社区.凡是涉及到对照两个句子或者实体关系的场合全然能够套用这个模型来解决.这点希望读者注意. 首 ...

  5. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers         本章中,你讲学到: 了解远程evernt ...

  6. [javase学习笔记]-7.7 thiskeyword的细节与应用

    这一节我们接着上一节来继续学习thiskeyword. 我们之前在7.5节中的构造函数应注意的细节中提到过一个细节就是构造函数能够调用一般函数,但一般函数不能直接调用构造函数.可是我们没有深究构造函数 ...

  7. Matlab得到二值图像中最大连通区域

    有时候要将二值化图像中最大的连通域保存下来.以下函数提供了一种方法: %function [img]=maxLianTongYu(I):求图像中最大的连通域 %输入:I 输入图像 %输出:img 仅包 ...

  8. Android Studio底边栏选项不见了,怎样调出来

    Android Studio底边有一个选项栏,包括了Run,Android等等非常多的选项,可是假设你一不小心不知道自己点到哪个地方了.底边选项栏不见了,怎样调出来.非常easy.例如以下图.地边栏不 ...

  9. 微软公有云Azure是惠及全人类的计算资源

    回归往事,1975年,微软以DOS创业.在随后的三十年中,微软给人类贡献了视窗操作系统Windows,至今,人们对桌面操作系统XP仍然不离不弃.可是,面对互联网的兴起.微软应该怎么办呢? 微软内部不乏 ...

  10. ios11--UIButton

    // // ViewController.m // 02-UIButton(在代码中使用) // #import "ViewController.h" @interface Vie ...