Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Your mod_python and mod_wsgi use different versions. That is the core problem as they must use the same version. Whether they use shared library is secondary issue and not usually an issue on MacOS X unless you are using hand built Python that wasn't configured properly.

Run:

otool -L mod_python.so
otool -L mod_wsgi.so

to determine the Python dependencies of each and whether shared library is used or not and update question with that output. Can then advise of next step.

In all though, it is strongly recommended not to use mod_python at same time as mod_wsgi and ideally you should drop mod_python altogether an migrate applications to a WSGI based solution.

Also, there is no such thing as MacOS 1.6.

share|improve this answer
    
Hi Graham, Thanks for your insight. I've updated the original question. Yes, for sure mod_wsgi is using Python 2.6. I thought that might be an issue, that's why I asked that second question. I do realize that mod_python as a project is officially dead and mod_wsgi should be used instead. There are a few other web applications running on the server that require mod_python and I will eventually be migrating these over one by one. Thanks for your help. Really appreciated! Chris P.s. Nice catch on the typo! haha "Mac OS 1.6" –  ChrisJF Aug 5 '10 at 15:56
    
Your mod_python is linked statically to Python and to a different version at that. Checkout mod_python source code from mod_python subversion repository and rebuild mod_python against latest Python version, ie., same as mod_wsgi using. Except in certain cases, the code in subversion repository should use Python framework (shared library on MacOS X). –  Graham Dumpleton Aug 5 '10 at 22:45
    
Hi Graham. I took your advice and ended up migrating all the web applications to mod_wsgi and disabling the mod_python module. Everything works great now. Thanks! –  ChrisJF Aug 12 '10 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.