Jan 26
I’ve been trying to run python scripts using Apache for a long time but finally I could install mod_python into our Mac Mini.
You can download mod_python from Apache web page:
http://httpd.apache.org/modules/python-download.cgi
Uncompress the source code and execute the configure script.
./configure --with-apxs=/usr/sbin/apxs
Then you have to patch the src/Makefile as follows:
- Add -arch x86_64 -arch ppc -arch i386 at the end of LDFLAGS variable
- Add -arch x86_64 -arch ppc -arch i386 at the end of CFLAGS variable
- 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)
Then you can compile and install this module:
make sudo make install
In order to test that mod_python works you can add the following lines at httpd.conf
<Location /mpinfo> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler mod_python.testhandler </Location>
Access to http://localhost/mpinfo and get this report:



January 26th, 2009 at 2:25 pm
This is not everything that needs to be fixed for it work all to work properly. For example, PSP pages will break. Rather than patch it yourself, just use latest source code from subversion repository.
svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk mod_python-trunk
It has all the required fixes, including some which are needed for newer Apache versions.
Better still, if you are only wanting to run a WSGI capable application such as Django or Trac, then use mod_wsgi instead. Using mod_python is not a good long term option at this point in time.
January 27th, 2009 at 9:13 am
@Graham, thanks for your comment.
I’m running a Trac, so probably I will install mod_wsgi
October 5th, 2009 at 12:26 pm
Path of httpd.conf is : /private/etc/apache2/httpd.conf
October 5th, 2009 at 12:37 pm
Before accessing localhost you need to add another line in httpd.conf:
“LoadModule python_module libexec/apache2/mod_python.so”
with the other loadmodule line’s.
Then you need to activate “web sharing” from system preferences in Mac OS
January 12th, 2010 at 10:00 am
Great, finally found an instruction to get mod_python working on MAc OSX that Actually works. Thanks very much! WHy is this information not on the apcahe mod_python pages…? Anyone knwo who to contact for that…?
Barend