I just got mod_python 3.1.3 up and running on Apache 2.0.49 on Mac OS X 10.3.4. Caveats: this is my own custom built from the source Apache, and you will need Fink installed with python 2.3 installed. If fink is already installed, just do a fink install python-23. Now the last step before we get started: if you open a terminal window, and type ‘python’, do you get python 2.3.3 (fink’s), or 2.3 (apple’s)? It is imperative that you end up opening the fink version of python (for dynamic loading reasons I won’t get into here). If you are not getting the fink version, try something like:
make
sudo make install (installs to /usr/local/apache2)
Then I compile and install mod_python:
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-python=/sw/bin/python2.3
make
sudo make install
Now, edit the httpd.conf to add the following line (mod_python does NOT do it for you)”
Now, start or restart apache:
Note that I used the full path here as Mac OS X ships with an apachectl in /usr/sbin.
That should be it. Follow the examples in the documentation at modpython.org and you should have a successful mod_python install.
Gotchas I encountered mainly have to do with file permissions mainly. If the nobody user cannot see the files you want to use, then they will not be served. I moved all of my development out of my home directory, since I did not want to mess with perms on my home directory and possibly invalidate my use of FileVault.
Happy Pythoning!!!
Popularity: 23%
September 2nd, 2004 at 9:34 pm
I’m really a newbie to Unix but do want to install mod_python and so I’ve tried to follow your instructions. I put a folder “apache2″ into usr/local and got through those instructions great. Then I put a folder “mod_python” into usr/local and typed in the ./configure command as you have it. I get a message saying that it doesn’t see -with-apxs2 and then it goes off and finds Apple’s apache 1.3, complains and quits. When I look through the directory structure apxs is exactly where your example says it should be. Any ideas?
September 2nd, 2004 at 9:44 pm
John-Raines-Computer:/usr/local/mod_python-3.1.3 jrraines$ ./configure -with-apxs2=/usr/local/apache2/bin/apxs -with-python=/sw/bin/python2.3
checking for gcc… gcc
checking for C compiler default output… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for ar… ar
checking for a BSD-compatible install… /usr/bin/install -c
checking whether make sets ${MAKE}… yes
checking for main in -lm… yes
checking for gcc option to accept ANSI C… none needed
checking for an ANSI C-conforming const… yes
checking your blood pressure… a bit high, but we can proceed
configure: checking whether apxs is available…
checking for –with-apxs… no
checking for apxs in /usr/local/apache/sbin… no
checking for apxs in your PATH… checking for apxs… /usr/sbin/apxs
found /usr/sbin/apxs, we’ll use this. Use –with-apxs to specify another.
checking Apache version… 1.3.29
configure: error: This version of mod_python only works with Apache 2. The one you have seems to be 1.3.29.
John-Raines-Computer:/usr/local/mod_python-3.1.3 jrraines$
September 2nd, 2004 at 9:49 pm
OK I found it. Your example says -with-apxs2=
should be -with-apxs=
now its working. Your page was enormously helpful thanks!!!
July 5th, 2005 at 6:01 pm
I tried this on Mac OSX 10.4. No problems with the installation, but once I tried to start apache through apachectl, I get the following error message:
Syntax error on line 233 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/module/mod_python.so into server: cannot create object file image or add library
s
Any ideas what the problem here is ?
(My config is apache 2.0.54, python2.3)
July 5th, 2005 at 8:45 pm
Stefan,
I have not yet tried it on 10.4, sorry.
July 12th, 2005 at 3:41 am
My apology for the last ‘rushed’ post. Was nothing else than a typo in the path.
I finally got it to work on OS X 10.4, the final issue I run into was that python would pick up it’s lib files from /usr/lib/python2.3 which is part of the mac installation an not the one I did myself (the -with-python option appearently has not effect on the lib paths). After pointing /usr/lib/python2.3 to /sw/lib/python2.3 everything worked well.
July 15th, 2005 at 2:50 pm
The question is, can you get mod_python compiled for the MacOS X (Tiger) Server native httpd and python install?
I fear there’s no easy (or even medium-hard, or sane) way, but maybe someone’s already gone to the more insane lengths than I have.
November 18th, 2008 at 5:54 am
I built out mod_python. so using the following config:
./configure -enable-so -with-apxs2=/Applications/xampp/xamppfiles/bin/apxs
make
sudo make install
Note: I modified two files to pass the compilation:
1, config.status
2, src/Makefile
removed the following words:
-arch ppc