I just went through getting set up for testing my Django apps under
mod_python as well as the test server.  For the sake any other users
trying to sort through this on Mac OS X, I thought I'd post what
finally worked for me (YMMV).  I assume you have a Django app working
under the test server, and you want to do what you think will be the
simple (haha) process of testing it under Apache locally.

Step 1: DevTools
We're going to be compiling from source.  This means you must have a
recent copy of OS X DevTools installed.  If you don't, go to
http://developer.apple.com/tools/ and download the newest fully-
released version (2.4 as of right now).  Fortunately, I already had
Xcode all set up.

Step 2: Apache 2.0
If you want to test Django under mod_python, you're going to need to
upgrade to Apache 2.0 instead of the Apache 1.3 you currently have, as
mentioned here:
    
http://www.djangoproject.com/documentation/install/#install-apache-and-mod-python.

After looking at a few options, I concluded right now compiling from
source was the best option, none of the packaged updates seem to be up-
to-date right now with the latest security patches.  Luckily, Apache
is a *very* clean build.  Download a 2.X version (as of this writing,
it's 2.2.6) from an apache.org mirror.  Then, look at the excellent
description of a Mac OS X setup for Apache here:
    http://switch.richard5.net/isp-in-a-box-v2/installing-apache-on-mac-os-x/
Note that if you're using csh or tcsh instead of BASH, the first
command to set up your CFLAGS should be:
     setenv CFLAGS "-arch i386 -isysroot /Developer/SDKs/
MacOSX10.4u.sdk"
instead of the bash syntax he's showing.

Step 3: mod_python
This was the most time-consuming part for me.  It starts out easy,
just download mod_python 3.x source from http://www.modpython.org/
(right now the released version is 3.3.1).  Unpack as usual.

The first step is to be sure to tell the configure program where your
Apache 2 installation is; if you followed the suggestions above it's
in /Library/Apache2.  So with just that, your configure command will
be:
    ./configure --with-apxs=/Library/Apache2/bin/apxs

If you're using the Mac OS 10.4 default Python installation (2.3.5)
which is installed as a Framework in /Library/Frameworks, you can
continue to step 4 from there.  However, I had upgraded to Python
2.4.3 and to remain version-locked with some other machines I really
wanted to keep using it.  This caused two complications.  The first
was to tell configure where my Python was, so my configure command
was:
    ./configure --with-apxs=/Library/Apache2/bin/apxs --with-python=/
usr/local/bin/python
That gets you through the configure, but it turns out to not quite
work.  If you build, install, and run the mod_python from there, when
you launch Apache you'll get an error in the error_log to this effect,
and mod_python is useless:
    [Mon Sep 24 13:21:56 2007] [error] python_init: Python version
mismatch, expected '2.4.3', found '2.3.5'.

Fortunately, Graham Dumpleton was nice enough to help me out, and
pointed out that after running configure but before running "make dso"
you need to edit the generated Makefile in src/Makefile.  He has a
note about this on his page at
    http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
For me, since I had Python 2.4.3 installed in /Library/Frameworks, the
LDFLAGS line became this:

LDFLAGS= -Wl,-F/Library/Frameworks  -u _PyMac_Error /Library/
Frameworks/Python.framework/Versions/2.4/Python   -arch ppc -arch i386
-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g

Step 4: Go Back to Work on your App!
Whew!  At that point, I finished compiling and installing mod_python,
then got to configuring my httpd.conf to reference mod_python, and
then finally got back to actually making my Django app work ;-)

Leo

P.S.  I should also point out that Graham advised not using mod_python
at all, and using mod_wsgi, which is supposed to work with the stock
Apache 1.3 and python 2.3.5.  My ultimate deployment server uses
Apache 2 so I stuck with the above, but for the sake of others I'll
pass along the reference I got:
  http://www.modwsgi.org
  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to