jeudi 27 mai 2021

FastCGI with LIGHTTPD in Python

I am currently trying to set up lighttpd server together with fastcgi enabled and in python language. However I have faced this error and after hours of googling, I cant seem to find a solution to it and I do not know what's causing the error as I am fairly new into this. Do take a look, and I hope that you will be able to help me! Thank you so much and have a nice day!

Important Details: Operating system --> Fedora Python version --> 3.9.4

The error I faced:

Traceback (most recent call last):
  File "/etc/lighttpd/conf.d/test.py", line 8, in <module>
    WSGIServer(myapp).run()
  File "/usr/local/lib/python3.9/site-packages/flup/server/fcgi.py", line 111, in run
    sock = self._setupSocket()
  File "/usr/local/lib/python3.9/site-packages/flup/server/fcgi_base.py", line 1025, in _setupSocket
    sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
  File "/usr/lib64/python3.9/socket.py", line 545, in fromfd
    return socket(family, type, proto, nfd)
  File "/usr/lib64/python3.9/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 88] Socket operation on non-socket

My python file, directory : /etc/lighttpd/conf.d/test.py:

#!/usr/bin/python3.9
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).run()

My fastcgi config file in directory: /etc/lighttpd/conf.d/fastcgi.conf

fastcgi.server = (
    ".py" =>
    (
        "python-fcgi" =>
        (
         "socket" => "/var/run/lighttpd/socketsfastcgi.python.socket",
         "bin-path" => "test.py",
         "check-local" => "disable",
         "max-procs" => 1,
        )
    ))

In my /var/run/lighttpd, theres a file socketsfastcgi.python.socket-0

(i tried to change my socket path to incorporate the -0 to become "/var/run/lighttpd/socketsfastcgi.python.socket-0" and it created a file socketsfastcgi.python.socket-0-0)




Aucun commentaire:

Enregistrer un commentaire