【发布时间】:2023-06-27 17:47:01
【问题描述】:
我正在 Raspberry Pi 上设置一个简单的 Web 服务器,但我似乎无法正确设置 lighttpd、fastcgi 和 flask。
到目前为止,我已经对/etc/lighttpd/lighttpd.conf 进行了几次迭代,最近的一次是
fastcgi.server = ("/test" =>
"test" => (
"socket" => "/tmp/test-fcgi.sock",
"bin-path" => "/var/www/py/test.fcgi",
"check-local" => "disable"
)
)
这在/etc/init.d/lighttpd start 上吐出一个错误。第一行看起来不对,所以我在粗箭头之后添加了一组括号:
fastcgi.server = ("/test" => (
...
))
这并没有吐出错误,但是当我尝试连接时,我在 Chrome 中得到了ERR_CONNECTION_REFUSED。然后我尝试删除"/test" =>,也遇到了同样的问题。我也试过this question,中显示的配置,同样的问题发生了。
在/var/www/py/test.fgci:
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from test import app
WSGIServer(app, bindAddress="/tmp/test-fcgi.sock").run()
在/var/www/py/test.py:
from flask import Flask
app = Flask(__name__)
@app.route("/test")
def hello():
return "<h1 style='color:red'>☭ hello, comrade ☭</h1>"
当我用/etc/init.d/lighttpd start 启动当前的lighttpd.conf 时,它会失败。
【问题讨论】: