gpt4 book ai didi

python - 让 flup fcgi 脚本正常工作很困难

转载 作者:行者123 更新时间:2023-12-01 06:18:19 42 4
gpt4 key购买 nike

我正在使用 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'

我希望能够找到这些退出状态的引用。

最佳答案

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

关于python - 让 flup fcgi 脚本正常工作很困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2013936/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com