Okay, so I have to use an existing server to run my Django web app on. The server is running Mac OS 10.6 Server. It comes with Python 2.3, 2.5, and 2.6 pre-installed. I have edited my http.conf file to include the following:
# Force python to run in main interpreter
WSGIApplicationGroup %{GLOBAL}
# Need the wsgi module to start django up, so point to the python file that will do that.
WSGIScriptAlias /webapp/ "/WebSites/django/webapp/apache/django.wsgi"
<Directory "/WebSites/django/webapp/apache/django.wsgi">
Order deny,allow
Allow from all
</Directory>
Both mod_python and mod_wsgi are definately being loaded by Apache. Proof:
$ apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
...
auth_user_host_apple_module (shared)
auth_session_apple_module (shared)
python_module (shared)
php5_module (shared)
wsgi_module (shared)
passenger_module (shared)
Syntax OK
And when the Apache server starts, my django.wsgi python file is run:
import os
import sys
path = '/WebSites/django/webapp'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'webapp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
So when the apache server runs, the follow is outputted in the apache error log:
[Wed Aug 04 11:39:19 2010] [notice] mod_python: Creating 8 session mutexes based on 1024 max processes and 0 max threads.
[Wed Aug 04 11:39:19 2010] [notice] mod_python: using mutex_directory /tmp
[Wed Aug 04 11:39:19 2010] [notice] Apache/2.2.14 (Unix) DAV/2 SVN/1.6.5 mod_python/3.3.1 Python/2.4.6 PHP/5.3.2 mod_wsgi/3.3 Python/2.6.1 Phusion_Passenger/2.2.11 configured -- resuming normal operations
Everything looks fine, until I go to the URL in my browser:
[Wed Aug 04 11:42:13 2010] [error] 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[Wed Aug 04 11:42:13 2010] [error] [GCC 4.2.1 (Apple Inc. build 5646)]
[Wed Aug 04 11:42:15 2010] [notice] child pid 78097 exit signal Segmentation fault (11)
Okay so I get a segmentation fault. I googled around and found this http://code.google.com/p/modwsgi/wiki/InstallationIssues#Using_ModPython_and_ModWsgi which is great because it exactly describes my problem. It instructs me to 1. compile python with --enable-shared or 2. to re-compile mod_wsgi. I am reluctant to compile python because it came pre-installed on Mac OS 10.6 Server.
So I chose option number two. I run ./configure
and then I open up the makefile like it says and look for the line LDLIBS = -lpython2.3 -lpthread -ldl -lutil
but I can't find it. The closest line I can find is LDLIBS = -ldl
but clearly I cannot remove the -lpython
if its not there. (I'm pretty sure the docs are for an older version of mod_wsgi.) I searched in the makefile for -lpython
but nothing comes up.
Does anyone know how to compile mod_wsgi 3.3 so that "the Python library is not actually linked with the mod_wsgi module." ??
As well, does this mean that mod_wsgi will use Python 2.6 or an older version that mod_python apparently uses?
Thank you so much for your help!
Update as requested by Graham Dumpleton:
$ otool -L mod_python.so
mod_python.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1)
$ otool -L mod_wsgi.so
mod_wsgi.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)