Ubuntu Hardy - mod_python Installation

Following from the django install article, we now look one way of serving our application.

mod_python is a simple to use (and setup) tool for serving python based web applications from Apache.

This article will walk you through installing and setting up mod_python with Apache.


Since we're focusing on Apache with mod_python, we'll need to have apache installed. You can follow this article specifically for detailed instructions or you can simply use the following command to install the necessary Apache componenets:

sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Note that if you follow the article you can safely skip the entire PHP section and simply use the Apache section unless you actually have a need to install PHP5. If you didn't follow the article and just used the command above now might be a good time to visit your slice IP in your browser and ensure you get the default "It works!" page from apache.

If you do not get the "It works!" page, apache may not have installed correctly, you may have an existing apache install, or iptables may be blocking port 80. Check all of those things before continuing as you will need a working and accessible install of apache to continue much further.

mod_python Installation

Installing mod_python is actually dead simple:

sudo aptitude install libapache2-mod-python

That is seriously all there is to it! You will want to give apache a restart (mod_python won't be enabled until you do).

sudo /etc/init.d/apache2 restart

In the next article we'll look at deploying a Django appliaction with mod_python

Ben H.

Article Comments:

Aleksey commented Thu May 14 14:22:55 UTC 2009:

"Deploying Django with Apache and mod_wsgi is the recommended way to get Django into production."

source: http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/

Maybe you should cover this option as well?

Ben H. commented Fri May 15 18:02:16 UTC 2009:

@Aleksey, I plan to tackle several methods for serving django applications. No worries! :)

Aleksey commented Sat May 16 11:01:37 UTC 2009:

@Ben, this would be great. Thanks for all the articles - you've saved me (and continue saving) lots and lots of time (:

TiredOfBadIdeas commented Thu May 21 22:47:09 UTC 2009:

mod_python is for developing apache modules.

mod_wsgi is for pythonic web applications.

i hope you reconsider wsgi for django. it's .. embarrassing and inappropriate to be using mod_python in this way.

OhApache commented Thu May 21 22:55:53 UTC 2009:

Sort of. modpython is for embedding a python interpreter into the httpd. It allows you to write handlers that then take care of .py requests. I have to agree, wsgi is the proper choice but with enough wrangling modpython will do what you want. The wsgi module or something like CherryPy will make everyone MUCH happier though!!

Ben H. commented Mon Jul 20 15:58:34 UTC 2009:

@TiredOfBadIdeas, @Aleksey

The mod_wsgi installation article has been published.


Soon to follow, using mod_wsgi to serve your Django application.

Want to comment?

(not made public)


(use plain text or Markdown syntax)