Install mod_python on Mac OS X

This is not my article, i copied it from here for safe keeping.

First, you?ll need to grab the source to mod_python. I recommend version 3.3.1, which is what I?ve worked with. Then, you?ll need to unpack it:

$ tar xvzf mod_python-3.3.1.tar
$ cd mod_python-3.3.1
$ ./configure --with-apxs=/usr/sbin/apxs

At that point, the configuration script will spit out a lot of things that you shouldn?t really care much about. Just make sure at the end it spits out a bunch of things about creating Makefiles. From there comes the normal sequence of events with most open source software:

$ make
$ sudo make install

The last requires the sudo command because it installs a bunch of pieces in privileged areas. Never run as root; always use sudo for your administrative needs. Finally, you need to add the module to your httpd.conf file, which is located in the /etc/apache2/directory, after making a back-up of course.

$ cd /etc/apache2
$ sudo cp httpd.conf httpd.conf.orig
$ sudo vi /etc/apache2/httpd.conf

Then, scroll down to where you?ll find all the LoadModule commands, and add another line:

LoadModule python_module /usr/libexec/apache2/mod_python.so

Now all that?s left is to reload Apache to make sure it loads the module for you:

$ sudo /usr/sbin/apachectl restart

At that point, you?re ready to proceed. The best place to start is the mod_python documentation, specifically the section on testing.

2 Comments

  1. See https://bugzilla.redhat.com/show_bug.cgi?id=465246 for a patch to fix the following make error on Snow Leopard macs running apr-util 1.3.4 (like mine =)

    [code]
    connobject.c:142: error: request for member 'next' in something not a structure or union
    apxs:Error: Command failed with rc=65536

  2. Cem says:

    1. Add -arch x86_64 -arch ppc -arch i386 at the end of LDFLAGS variable
    2. Add -arch x86_64 -arch ppc -arch i386 at the end of CFLAGS variable
    3. Modify mod_python.so objective as follows:
    Add -Wc,”-arch x86_64″ -Wc,”-arch ppc” -Wc,”-arch i386″ after the -c
    In my situation: $(APXS) $(INCLUDES) -c -Wc,”-arch x86_64″ -Wc,”-arch ppc” -Wc,”-arch i386″ $(SRCS) $(LDFLAGS) $(LIBS)

Leave a Reply