6

I have nginx running on a VM and I want to run a Trac site. I need to run a python FastCGI server, but I cannot tell which is the server to use. I have found the following:

  • Lighttpd spawn-fcgi But this seems to require that you compile lighttpd just to get the fcgi server, which is weird.
  • fcgi.py But this one seems to be deprecated. At the very least it is poorly documented.
  • flup This one comes with dependencies on ubuntu (python-cheetah{a} python-mysqldb{a} python-webpy{a}) that seem unnecessary. Also poorly documented.

Are there any recent guides for setting this up? Trac's own FastCGI setup page seems to miss some steps.

Rob
  • 185

3 Answers3

3

trac should be now WSGI compliant, so you can use any supported method to run the site. If it is a low traffic site, you can always use CGI, and eventually move to something else later if you need it. For the other methods, use mod_wsgi or install flup for FCGI (even if it installed extra dependencies).

To use flup, you have to import the appropriate WSGI server, then run it, i.e.

from flup.server.fcgi_fork import WSGIServer
def main_app(...):
  ...

WSGIServer(main_app).run()

If you want to run it as external server (i.e. not started by the web server), substitute this:

WSGIServer(main_app,bindAddress=('1.2.3.4',9999)).run()
1

Well man, flup is used by Django itself. Its an awesome method to run python fastcgi applications unless you have a mod_wsgi or something similar.

The code to run flup is:

from flup.server.fcgi import WSGIServer

def app(environ, start_response):
  start_respone('200 OK', [('Content-Type', 'text/plain')])
  yield "Hello World"

WSGIServer(app).run()
Nilesh
  • 289
0

Why FastCGI in particular? In Python, there's a standard interface for writing web server apps, called WSGI. Various servers provide frameworks for doing this; eg, mod_wsgi for Apache. For nginx, there appears to be: http://wiki.nginx.org/NginxNgxWSGIModule which is even based on mod_wsgi.

Phil P
  • 3,110