Sunday 17 March 2013

Web.py, Lighttpd and FastCGI

 

Following the instructions from http://webpy.org/install and http://webpy.org/docs/0.3/tutorial I had setup Lighttpd.

However, when running the demo code the following error was received

 

2013-03-17 23:04:19: (mod_fastcgi.c.1490) released proc: pid: 8806 socket: unix:/var/tmp/lighttpd/fastcgi.socket-0 load: 0
2013-03-17 23:14:50: (mod_fastcgi.c.1732) connect failed: Connection refused on unix:/var/tmp/lighttpd/fastcgi.socket-0
2013-03-17 23:14:50: (mod_fastcgi.c.454) backend disabled for 1 seconds
2013-03-17 23:14:50: (mod_fastcgi.c.3002) backend died; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 1

Checking the script showed that it was working correctly and no useful information was appearing in error.log

The following config option was then added to lighttpd.conf

server.breakagelog          = "/var/log/lighttpd/breakage.log"

This gives the much more useful

Traceback (most recent call last):
  File "/var/www/code.py", line 16, in <module>
    app.run()
  File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 313, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
  File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/wsgi.py", line 35, in runwsgi
    return runfcgi(func, None)
  File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/wsgi.py", line 16, in runfcgi
    import flup.server.fcgi as flups
ImportError: No module named flup.server.fcgi

This was unexpected as I had already used easy_install to install flup, but upon checking could find no evidence of it being installed

The latest egg was downloaded from https://pypi.python.org/pypi/flup and installed using easy_install.

The installation process was then checked by making sure flup could be imported.