Nginx使用cgiwrap-fcgi.pl支持CGI,但频繁Resource temporarily unavailable

使用Nginx解析CGI的同学应该都看到过这个:

http://wiki.nginx.org/SimpleCGI

保存为cgiwrap-fcgi.pl后,就可以解析bash等cgi程序了


但在实际使用经常遇到如下问题:

2012/08/06 15:35:16 [error] 8483#0: *147071273 connect() to unix:/dev/shm/cgiwrap-dispatch.sock failed (11: Resource temporarily unavailable) while connecting to upstream...


原因和php-fpm遇到Resource temporarily unavailable时的原因一样,backlog设置的不够大。


解决方法:

源代码第35行左右,FCGI::OpenSocket

  1.   $socket = FCGI::OpenSocket( "/dev/shm/cgiwrap-dispatch.sock", 10 )  
  2.   ; #use UNIX sockets - user running this script must have w access to the 'nginx' folder!!

经过查询http://search.cpan.org/~skimo/FCGI-0.67/FCGI.PL

得知:

FCGI::OpenSocket(path, backlog)
Creates a socket suitable to use as an argument to Request.

path
Pathname of socket or colon followed by local tcp port. Note that some systems take file permissions into account on Unix domain sockets, so you'll have to make sure that the server can write to the created file, by changing the umask before the call and/or changing permissions and/or group of the file afterwards.

backlog
Maximum length of the queue of pending connections. If a connection request arrives with the queue full the client may receive an error with an indication of ECONNREFUSED.

所以只需将FCGI::OpenSocket的第二个参数改大即可,例如

  1.   $socket = FCGI::OpenSocket( "/dev/shm/cgiwrap-dispatch.sock", 1024 )  
  2.   ; #use UNIX sockets - user running this script must have w access to the 'nginx' folder!!

另外需要注意的是

/dev/shm/cgiwrap-dispatch.sock

这个文件的所属用户和所属组,nginx要能够对这个文件进行w操作,因此别忘了:

chown nginx.nginx /dev/shm/cgiwrap-dispatch.sock




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值