1

我正在为使用 django 的客户建立一个站点。它已托管在共享主机上,无法使用 mod_wsgi。在过去的一年里,我使用 fcgi 让它工作,但是当我回来时,它就坏了。

我已经用一个简单的 hello world 脚本替换了 fcgi 脚本:

#!/usr/bin/python
def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello World!\n']

try:
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp).run()
except:
    import sys, traceback
    traceback.print_exc(file=open("errlog.txt","a"))

在我的本地服务器上测试和工作,但在托管服务器上,我收到此错误:

<title>FCGI Error</title>
A timeout occured while waiting for the script output (in: /usr/www/users/mymemb/).

如果我查看错误日志,我会看到:

[Wed Jan  6 16:59:37 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (user mymemb, gid 100) restarted (pid 1057)

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (pid 1057) terminated by calling exit with status '118'

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

etc ...

如果我 ssh 到服务器,我可以很好地运行脚本,输出如下:

mymemb@www81:~/public_html$ ./mymembers.fcgi 
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/plain
Content-Length: 13

Hello World!

我该如何解决?

添加信息:

脚本似乎根本没有运行。如果我在脚本顶部添加 import x 并从 ssh 运行它,我会看到 x.pyc 已创建。如果我 rm x.pyc,然后点击该站点,则不会创建 x.pyc。

我还注意到错误从

terminated by calling exit with status '118'

terminated by calling exit with status '116'

我希望我能找到这些退出状态的参考。

4

2 回答 2

2

退出状态 116 和 118 来自 suexec。通过阅读源代码,我发现这些错误是由组或其他人可写的文件/目录引起的,suexec认为这是一个安全问题。从组中删除写访问权解决了这个问题。

于 2010-01-10T20:51:36.800 回答
0

嘿,谢谢!我只会粘贴评论。

  • 您使用什么服务器来运行 mymembers.fcgi ?– 东武
  • Debian Etch, Apache 1.3 网址是 mymembers.co.za – Gary van der Merwe
  • 我怀疑 mod_fastcgi 配置错误。请发布或粘贴您的 apache 配置的相关部分。– 东武
  • 由于这是托管在共享主机上,所以我没想过要查看配置。查看配置帮助我找到了问题,所以你真的帮助了我。我希望我能够将赏金奖励给你。meta.stackoverflow.com/questions/35081/… – 加里·范德默维
于 2010-01-10T21:12:37.770 回答