fcgiwrap使nginx执行访问后缀为cgi的文件

fcgiwrap可以支持nginx访问后缀为cgi的文件
Centos5.7 64位安装:
#yum install -y git-core build-essential libfcgi-dev autoconf lib tool automake
#cd /usr/local/src/ 

#git clone git://github.com/gnosek/fcgiwrap.git
#cd /usr/local/src/fcgiwrap
#autoreconf -i


这里autoconf有版本要求:
# autoreconf -i
configure.ac:4: error: Autoconf version 2.61 or higher is required
configure.ac:4: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
configure.ac:4: error: Autoconf version 2.61 or higher is required
configure.ac:4: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
autoreconf: /usr/bin/autoconf failed with exit status: 63

# autoreconf -V
autoreconf (GNU Autoconf) 2.59
Written by David J. MacKenzie and Akim Demaille.
升级一下

http://ftp.gnu.org/gnu/autoconf/  下载最新的

# tar xfv autoconf-latest.tar.gz 
# cd autoconf-2.69/
# ./configure --prefix=/usr/local/autoconf
# make && make install
# cd    /usr/local/src/fcgiwrap
/usr/local/autoconf/bin/autoreconf -i
然后就可以继续安装   fcgiwrap了
# ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for FCGX_Init in -lfcgi… no
configure: error: FastCGI library is missing

又没有FastCGI包。然后继续想办法安装
# rpm -Uvh epel-release*rpm
# yum install fcgi-devel -y  

然后继续安装
# ./configure
#make && make install  
#mv  fcgiwrap  / usr / local / bin /

#vim /etc/init.d/fcgiwrap
#!/usr/bin/perl
 
use strict;
use warnings FATAL => qw( all );
 
use IO::Socket::UNIX;
 
my $bin_path = '/usr/local/bin/fcgiwrap';
my $socket_path = $ARGV[0] || '/tmp/cgi.sock';
my $num_children = $ARGV[1] || 1;
 
close STDIN;
 
unlink $socket_path;
my $socket = IO::Socket::UNIX->new(
    Local => $socket_path,
    Listen => 100,
);
 
die "Cannot create socket at $socket_path: $!\n" unless $socket;
 
for (1 .. $num_children) {
    my $pid = fork;
    die "Cannot fork: $!" unless defined $pid;
    next if $pid;
 
    exec $bin_path;
    die "Failed to exec $bin_path: $!\n"; 
}

chmod +x /etc/init.d/fcgiwrap

然后在nginx配置里面:
 fastcgi_pass. "fastcgi_pass unix:/tmp/cgi.sock;"

可以查看日志发现权限不对
chmod 777 /tmp/cgi.sock
好了,这样就可以访问了

我的nginx配置:
location ~ .*\.cgi$ {
                include fastcgi_params;
                fastcgi_pass    unix:/tmp/cgi.sock;
                fastcgi_index   smokeping.cgi;
                fastcgi_param   SCRIPT_FILENAME /var/www/html/smokeping/htdocs$fastcgi_script_name;
                }
这样我就用nginx来访问smokeping的页面了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向良玉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值