Building mod_python on Leopard
Since I’ve been doing a lot of work in Django lately, I’ve been meaning to set up mod_python with the Apache distribution in Leopard so that I can get a bit closer to the production environment. The default built-in webserver is great for development, but it won’t let me debug the last bit of production issues. To do that, I’m gonna walk through the steps. They’re largely the same as any other UNIXish system, but that doesn’t mean everyone on Mac OS X is steeped in UNIXisms.
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.
Good luck!
This entry was posted at 10:58 pm on 6 December 2007 and is filed under Mac. You can follow any responses to this entry through the post-specific RSS 2.0 feed.
Both comments and pings are currently closed.
On Intel Macs, you’ll experience problems following this guide exclusively. mod_python compiles for a 32bit architecture, whereas (on an Intel Mac) httpd runs as 64bit.
The article at [1] describes how to modify the Makefile accordingly.
[1] http://www.webmonkey.com/blog/Tips_And_Tricks_For_Web_Development_In_OS_X_Leopard