Installing mod_python on Mac OS X Leopard (10.5.x)
Apache2 comes pre installed on Mac OS X Leopard as does Python (2.5). But it doesn't come with mod_python. Here is what you need to do to get it to work.
download the latest file from http://www.apache.org/dist/httpd/modpython/ I downloaded (mod_python-3.3.1.tgz)
$ tar xvzf mod_python-3.3.1.tgz
$ cd mod_python-3.3.1
$ ./configure --with-apxs=/usr/sbin/apxs
Now we need to patch the make file so that it will work correctly. edit src/MakeFile
- Add -arch x86_64 -arch ppc -arch i386 to the end of the LDFLAGS line.
- Add -arch x86_64 -arch ppc -arch i386 to the end of the CFLAGS line.
- Under the mod_python.so target add the following to the line after the -c -Wc,"-arch x86_64" -Wc,"-arch ppc" -Wc,"-arch i386" so my complete line looks like. $(APXS) $(INCLUDES) -c -Wc,"-arch x86_64" -Wc,"-arch ppc" -Wc,"-arch i386" $(SRCS) $(LDFLAGS) $(LIBS)
When that is done:
$ make
$ sudo make install
and then:
$ cd /etc/apache2
$ sudo cp httpd.conf httpd.conf.orig
$ sudo emacs /etc/apache2/httpd.conf
Add the following to the httpd.conf file.
LoadModule python_module libexec/apache2/mod_python.so
Restart apache
$ sudo /usr/sbin/apachectl restart
Test configuration
sudo /usr/sbin/apachectl -t
That is all, if there are no errors, it worked!
Labels: django, mod_python, OSX