12
votes

I'm setting up a simple web server on my Raspberry Pi and I can't seem to set up lighttpd, fastcgi, and flask correctly.

By now, I've gone through a few iterations of /etc/lighttpd/lighttpd.conf, the most recent one being

fastcgi.server = ("/test" =>
    "test" => (
        "socket" => "/tmp/test-fcgi.sock",
        "bin-path" => "/var/www/py/test.fcgi",
        "check-local" => "disable"
    )
)

That spat out an error on /etc/init.d/lighttpd start. The first line looked wrong, so I added a set of parens after the fat arrow:

fastcgi.server = ("/test" => (
...
))

This didn't spit out an error, but when I tried to connect, I get ERR_CONNECTION_REFUSED in Chrome. Then I tried removing "/test" =>, and that had the same problem. I have also tried the config shown in this question, and the same problem occurred.

In /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()

In /var/www/py/test.py:

from flask import Flask
app = Flask(__name__)

@app.route("/test")
def hello():
    return "<h1 style='color:red'>&#9773; hello, comrade &#9773;</h1>"

The current lighttpd.conf fails when I start it with /etc/init.d/lighttpd start.

1

1 Answers

0
votes

I can't really help you with the Python part as it is outside of my skillset, however when running php as a fcgi server i would use a lighttpd.conf like the following.

fastcgi.server += ( ".php" =>
    ((
        "host" => "127.0.0.1",
        "port" => "9000",
        "broken-scriptfilename" => "enable"
    ))
)

So I would assume that something like the following is what you need for python.

fastcgi.server += ( "/test" =>
    ((
        "socket" => "/tmp/test-fcgi.sock",
        "bin-path" => "/var/www/py/test.fcgi",
        "check-local" => "disable"
    ))
)