0

I have a lighttpd server that I want to run a python application using fastcgi. I followed the example on the lighty homepage, but I can't seem to get lighty to execute the python script. This is my fastcgi section in 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,
        )
    ))

This is the content of 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()

When I restart lighty with this configuration, I can see that the python process is started and I don't get any error from lighty. However, when I go to https://localhost:444/test.py it just keeps loading forever. Nothing is written in access.log or error.log. If anyone could give me a hint on how to investigate this I would be grateful.

EDIT: I enabled fastcgi.debug, and this is written to the error log when I go to the URL mentioned above. It still keeps loading forever:

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 
3
  • You already posted on the lighttpd forum (redmine.lighttpd.net/boards/2/topics/8671) and were directed to documentation with explicit examples (redmine.lighttpd.net/projects/lighttpd/wiki/HowToPythonWSGI). If you haven't yet tried the explicit examples, then you should try them. Commented Jul 26, 2019 at 23:34
  • @gstrauss what I posted here (and what I can not get to work) is the explicit example mentioned in the link you posted (under Python WSGI apps via FastCGI or SCGI using the flup server). I tried fastcgi and scgi, that did not make a difference. Commented Jul 27, 2019 at 8:30
  • wrote "what I posted here ... is the explicit example mentioned." No, no it is not. Your cut-n-paste skills are sloppy. Your cut-n-paste seem to have added python code to the ~6 line sample. Commented Jul 28, 2019 at 5:39

1 Answer 1

1

bindaddress should not be specified in WSGIServer() Python code when lighttpd starts up the FastCGI using "bin-path"

Sign up to request clarification or add additional context in comments.

2 Comments

I had already tried both (with and without bindAddress), and none worked. What does work, however, is putting in bindAddress and deleting the bin-path option and starting the WSGI server manually, so thank you for that :) Any idea why the bin path option doesn't work?
The bin-path to lighttpd works, as you might find if you use a different socket name. You probably still had conflicting use of that socket you when you tried, whether it be one or more versions of your app running with bindAddress, or you did not properly restart lighttpd after making config changes. Until you have made multiple attempts to rule out your own actions, please stop assuming that it is someone else's fault when you can't get something to work. Then, when reporting a problem, share in detail the different things that you tried and what you observed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.