配置Lighttpd以使用fastcgi运行python脚本

2024-05-14 20:08:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个lighttpd服务器,我想用fastcgi运行python应用程序。我遵循了example on the lighty homepage,但似乎无法轻松地执行python脚本。这是我的fastcgi部分lighttpd.conf文件地址:

fastcgi.server = (
    ".py" =>
    (
        "python-fcgi" =>
        (
         "socket" => "/tmp/fastcgi.python.socket",
         "bin-path" => "/usr/bin/login_flask/fcgitest.py",
         "check-local" => "disable",
         "max-procs" => 1,
        )
    ))

这是本书的内容fcgitest.py公司地址:

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

if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp, bindAddress="/tmp/fastcgi.python.socket").run()

当我用这个配置重新启动lighty时,我可以看到python进程已经启动,我没有从lighty得到任何错误。但是,当我转到https://localhost:444/test.py时,它会一直加载。什么都没写访问.log或者错误.log. 如果有人能给我一个如何调查此事的提示,我将不胜感激。你知道吗

编辑:我已启用快速cgi.debug,当我转到上面提到的URL时,这会写入错误日志。它仍然永远在加载:

2019-07-26 11:53:26: (gw_backend.c.914) gw - found a host  0 
2019-07-26 11:53:26: (gw_backend.c.227) got proc: pid: 2628 socket: unix:/tmp/fastcgi.python.socket-0 load: 1 

Tags: pybinserverusr错误socketfastcgistart

热门问题