Install mod_python on Mac OSX 10.6 (Snow Leopard)

  1. Grab source of Mod_python. Actually 3.3.1.
  2. Unpack with your favourite tool
  3. Change to source directory
  4. Follow steps below

    $ ./configure --with-apxs=/usr/sbin/apxs
    $ make

    Compilation will fail with this error:

    connobject.c: In function _conn_read:
    connobject.c:142: error: request for member next in something not a structure or union
    apxs:Error: Command failed with rc=65536
  5. Download this patch for src/connobject.c

  6. Save it to the same directory you saved mod_python (presumably the Downloads directory of OS X)
    $ cd ..
    $ patch -p0 < mod_python-3.3.1-apr.patch
    $ cd mod_python-3.3.1
    $ make
    $ sudo make install

Now the module resides in /usr/libexec/apache2. To finish the installation, you need to add mod_python to your httpd.conf:

$ sudo vi /etc/apache2/httpd.conf

and add

LoadModule python_module libexec/apache2/

After restarting apache you are ready to use python.

2011-01-07: Rewrote the patch-part