Nginx+nagios安装配置
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安装配置的更多相关文章
- nginx初级安装配置
nginx初级安装配置 转自:(lykyl原创)http://www.cnblogs.com/lykyl/archive/2012/11/21/2781077.html 实验环境:系统 CENTOS5 ...
- nginx+tomcat安装配置
nginx+tomcat安装配置 # nginx+tomcat安装配置 #创建网站目录 mkdir -p /www/wwwroot cd /www #安装配置 wget http://mirrors. ...
- gerrit+nginx+centos安装配置
安装环境 centos 6.8 gerrit-full-2.5.2.war 下载地址:https://gerrit-releases.storage.googleapis.com/gerrit-ful ...
- Nginx的安装配置和tomcat负载均衡
Nginx简介 什么是nginx? Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.由俄罗斯的程序设计师Igor Sysoev所开发,官方测试ngi ...
- nginx php-fpm安装配置 CentOS编译安装php7.2
CentOS编译安装php7.2 介绍: 久闻php7的速度以及性能那可是比php5系列的任何一版本都要快,具体性能有多好,建议还是先尝试下再说.如果你是升级或新安装,那你首先需要考虑php7和程序是 ...
- 吴裕雄--天生自然Django框架开发笔记:Django Nginx+uwsgi 安装配置
Django Nginx+uwsgi 安装配置 使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,需要一个可以稳定而持续的服务器,比如 ...
- centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置
前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...
- Nginx服务安装配置
1.Nginx介绍 Nginx是一个高性能的HTTP和反向代理服务器,由俄罗斯人开发的,第一个版本发布于2004年10月4日.Nginx由于出色的性能,在世界范围内受到了越来越多人的关注,其特点是占有 ...
- Django Nginx+uwsgi 安装配置
使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache, Nginx, lighttp ...
随机推荐
- MAPZONE GIS SDK接入Openlayers3之四——高级标注效果实现
首先看实现效果: 实现要点: 1)树形标注实现 2)复杂标注样式定义 3)效率优化 1.树形标注实现 树形标注采用字体符号来实现,包括以下几个步骤 1)载入字体 2)设置标注值与字体对照关系 3)设置 ...
- 交换机是干嘛的!!交换机如何学习MAC地址过程?
1.它收到一个帧的时候,先检查源MAC地址,看看自己维护的一个地址表中有没有这个地址.如果有,则2:如果没有,则将这个MAC地址.进入的端口.进入的时间放入这个表中: 2.检查目的MAC地址,然后到该 ...
- autoconfig
實例:假設我們有個資料夾為d:\tmp和e:\tmp ,而我們只要將d:\tmp中有異動的檔案複製到e:\tmp下的話,用法如下xcopy d:\tmp\. e:\tmp\ /D /S /Y實例:如果 ...
- 查看程序占用tomcat内存情况
近期,公司线上tomcat常常无缘无辜宕机.总结了一下定位问题的方法,仅供參考: 报错信息: Maximum number of threads (200) created for connector ...
- UVa 11475 - Extend to Palindrome
題目:給你一個字符串,在後面拼接一部分使得它變成回文串,使得串最短.輸出這個回文串. 分析:KMP,dp.這裡利用KMP算法將串和它的轉置匹配,看結束時匹配的長度就可以. 因為串比较長.使用KMP比较 ...
- mac 显示隐藏文件的命令行和快捷键
命令行方式: 显示隐藏文件: defaults write com.apple.Finder AppleShowAllFiles YES;KillAll Finder 不显示隐藏文件: default ...
- css高级:font-size
body{ font:62.5%/1.6em "Lucida Grande",Verdana,Geneva,Helvetica,Arial,sansserif; }//font-s ...
- CSS里面position:relative与position:absolute 区别
position:absolute这个是绝对定位:是相对于浏览器的定位.比如:position:absolute:left:20px;top:80px; 这个容器始终位于距离浏览器左20px,距离浏览 ...
- CJOJ1857 -PG图
Description 背景 LDN不知道为什么特别喜欢PG,也许是某种原因吧…… 有一天,他发明了一个游戏“PG图”. 问题描述 给定一个有向图,每条边都有一个权值. 每次你可以选择一个节点u和一个 ...
- bzoj1297 [SCOI2009]迷路——拆点+矩阵快速幂
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1297 一看感觉是矩阵快速幂之类的,但边权不好处理啊: 普通的矩阵快速幂只能处理边权为1的,所 ...