tech stuff.

Installing Apache modules on Mac OS X Leopard

with 2 comments

Installing mod_python on my mac laptop was surprisingly difficult.  My first attempt of simply compiling it with {LD,C}FLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64" failed in a bit of a strange way.  It appeared to create a universal binary for the DSO, but apache failed to load it with the following error message:

httpd: Syntax error on line 118 of /Volumes/Workplace/pflex/2.1.x/Build/build/ValidationWeb/apache/etc/httpd.conf: Syntax error on line 22 of /Volumes/Workplace/pflex/2.1.x/Build/build/ValidationWeb/apache/etc/platform/i386.Mac OS X/httpd.conf: Can't locate API module structure `python_module' in file /usr/libexec/apache2/mod_python.so: dlsym(0x100201000, python_module): symbol not found

As it turns out, the build process was respecting the LDFLAGS & CFLAGS for processes called directly by make, but it was not passing them on to apxs.  Adding the following to src/Makefile (after the initial INCLUDE declaration) worked to put apxs on the right track:

INCLUDES+= -Wc,-arch -Wc,ppc -Wc,-arch -Wc,ppc64 -Wc,-arch -Wc,i386 -Wc,-arch -Wc,x86_64
INCLUDES+= -Wl,-arch -Wl,ppc -Wl,-arch -Wl,ppc64 -Wl,-arch -Wl,i386 -Wl,-arch -Wl,x86_64

So, the procedure to install mod_python is:

  1. Download source here
  2. ./configure
  3. Add above two lines to src/Makefile
  4. make
  5. sudo make install or sudo make install_dso
Advertisements

Written by Lee Verberne

2008/11/19 at 17:48

2 Responses

Subscribe to comments with RSS.

  1. Bless you for this post . . . you just cleared up two hours of frustration!

    Dave Haas

    2008/12/15 at 00:44

  2. Hmmm, seems my last comment hasn’t been accepted, so will try again with some more information.

    Note that the information in original post is not enough to get mod_python working correctly on MacOS X under 64 bit Apache. This will only fix up mod_python module itself and will not result in Python C extension modules the package installs being compiled correctly. That is, the PSP handler for mod_python will fail.

    The better approach is to check out latest mod_python from subversion repository and use that, as it includes all the required fixes to get it working.

    svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk mod_python
    cd mod_python
    ./configure
    make
    sudo make install

    BTW, you cannot only do ‘make install_dso’ as original post suggests as that only installs Apache module and not the Python package component.

    FWIW, if you didn’t care about PHP handler, or even publisher handler for that matter, you shouldn’t use mod_python anyway as there are better options for Python hosting in conjunction with Apache these days.

    Graham Dumpleton

    2009/01/07 at 23:09


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: