Running python through fastCGI for nginx

WilHall picture WilHall · Aug 13, 2011 · Viewed 40.1k times · Source

I am looking to run standalone python scripts through fcgi for use with nginx, but I have no idea where to start with spawning the processes. Currently, I have PHP successfully with nginx+fcgi, but I'm unsure if/how I can do the same with python. Any suggestions on where to start?

Answer

agf picture agf · Aug 13, 2011

See the python docs section on FCGI. Basically, with Python, you use the WSGI interface on top of an fcgi server which talks to the web server (the fcgi client).

See Python + FastCGI for a couple of Python fcgi servers.

Edit:

This nginx wiki page explains exactly how to set up Python with nginx using fcgi.

This wiki page describes the uWSGI module for nginx, which is the natural way to use Python with a web server, if you don't really need to use fcgi. This blog entry also looks like good info on uWSGI.

In production, Apache + mod_wsgi or Nginx + mod_wsgi? has some useful info for nginx mod_wsgi as well.