Friday, January 23, 2009

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: , ,

3 Comments:

At 10:45 AM, Anonymous Anonymous said...

Exactly what I needed. This solved my problem.

 
At 10:56 AM, Blogger Reinholdt said...

Hi Ken

I got the following errors!

make[1]: *** [mod_python.so] Error 1
make: *** [do_dso] Error 2 MacBookPro:mod_python-3.3.1 morten$ ld warning: in .libs/finfoobject.o, missing required architecture x86_64 in file
ld warning: in .libs/hlistobject.o, missing required architecture x86_64 in file
ld warning: in .libs/hlist.o, missing required architecture x86_64 in file
ld warning: in .libs/filterobject.o, missing required architecture x86_64 in file
ld warning: in .libs/connobject.o, missing required architecture x86_64 in file
ld warning: in .libs/serverobject.o, missing required architecture x86_64 in file
ld warning: in .libs/util.o, missing required architecture x86_64 in file
ld warning: in .libs/tableobject.o, missing required architecture x86_64 in file
ld warning: in .libs/requestobject.o, missing required architecture x86_64 in file
ld warning: in .libs/_apachemodule.o, missing required architecture x86_64 in file
ld warning: in .libs/mod_python.o, missing required architecture x86_64 in file

Do you have any ideas how I can correct this

 
At 11:30 AM, Blogger Ken Cochrane said...

@Reinholdt

I'm not 100% sure, but I am guessing that you are trying to get a 32bit lib to work with a 64bit apache..

If apache is configured as 64bit then your libs/modules need to be 64bit as well.

 

Post a Comment

Links to this post:

Create a Link

<< Home