49

I've been playing around with my own webserver (Apache+Ubuntu) and python. From what I've seen there are 3(?) main ways of doing this:

  1. Apache configured to handle .py as cgi
  2. Apache configured to use mod_python that is now outdated(?)
  3. Apache configured to use mod_wsgi

I recall reading that Django prefers mod_wsgi, and I'm kinda interested in learning Django (I've heard their official tutorial is rather excellent).

What is the 'recommended' setup? I presume there's really no reason to use mod_python anymore, but what are the differences between handling .py as cgi, and mod_wsgi? Is it possible to run them in tandem (and would you want to?), or is that just a ridiculous idea and I should stop thinking such crazy things?

I guess really I'm just looking for a primer on Apache+Python (links are also good) - nothing I've come across so far has been terribly informative - they were mainly just how-to's.

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290

4 Answers4

38

mod_python is dead, so using mod_python probably isn't a good idea for new projects. Personally, I prefer to use mod_wsgi over CGI (or FastCGI). It's dead-simple to set up, and much more efficient.

mipadi
  • 398,885
  • 90
  • 523
  • 479
  • 16
    Rebuttal from mod_python site: 'Currently mod_python is not under active development. This does not mean that it is "dead" as some people have claimed. It simply means that the code and the project are mature enough when very little is required to maintain it.' (http://www.modpython.org/) – Chris Redford May 05 '13 at 15:09
  • 6
    Also, it's under active development again, with a new release in November 2013. – nedned Feb 03 '14 at 02:15
21
  1. Don't use CGI. It's inefficient. Spawning a new process for each request. No thanks

  2. Dont't spend much time with mod_python

  3. Use mod_wsgi.

If you want to write CGI-like stuff without a framework, use mod_wsgi anyway. The WSGI standard (PEP 333) is essential for creating web applications in an easy, interchangeable, reusable, plug-and-playable way.

S.Lott
  • 384,516
  • 81
  • 508
  • 779
9

Mod_Python

mod_python is alive and well. See here: http://modpython.org/. Furthermore, here's the documentation for the latest release, 3.5.0, with support for Python 3: http://modpython.org/live/current/modpython.pdf. Currently I use it.

Mod_WSGI

mod_wsgi thinks of itself as not to be used barebones, but with a framework, such as Flask.

cptaffe
  • 426
  • 3
  • 8
9

I would go with mod_wsgi too.

If you want a deeper understanding about the question, have a look at this:

Good stuff!

ssoler
  • 4,884
  • 4
  • 32
  • 33