Help running Django with mod_python

11 views
Skip to first unread message

Paolo

unread,
Dec 1, 2005, 9:29:29 AM12/1/05
to django...@googlegroups.com
I'm trying to setup Django with Apache and mod_python.

I have followed the procedure described in the document "how to use
Django with mod_python", but I can't obtain a working basic (single
Django installation on the same Apache) environment, because Apache
unexpectedly crashes at each request.

It happens that a blank page (no response) is returned to the browser
when a request is made.

These strings appear in error_log:
[Thu Dec 01 11:03:47 2005] [notice] mod_python: Creating 32 session
mutexes based on 150 max processes and 0 max threads.
[Thu Dec 01 11:03:47 2005] [notice] Apache/2.0.55 (Unix)
mod_python/3.1.4 Python/2.3.5 configured -- resuming normal operations
[Thu Dec 01 11:07:12 2005] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Thu Dec 01 11:07:13 2005] [notice] child pid 15299 exit signal
Segmentation fault (11)

Looking around for some pointer I have discovered that some
incompatibilities might generate this problem. It is the case (but
there are others) of embedded Python's version of expat and Apache's
linked version of expat that differ. However in my setup they are the
same.

As I have spent a lot of time on this without results, and the cause
of this bad behavior maybe is something simple for an experienced
user, I'd really love some help.

Thanks in advance!

Afternoon

unread,
Dec 1, 2005, 9:48:06 AM12/1/05
to django...@googlegroups.com

On 1 Dec 2005, at 14:29, Paolo wrote:

> [Thu Dec 01 11:07:13 2005] [notice] child pid 15299 exit signal
> Segmentation fault (11)

Ah, I spent a frustrating few hours wrestling with this error (or one
like it) last night. Are you using mod_python 3? After building
mod_python have you fully restarted Apache or just gracefully
restarted it?

________________________________
Afternoon, man about the Internet -- http://aftnn.org/


Paolo

unread,
Dec 1, 2005, 10:24:21 AM12/1/05
to django...@googlegroups.com
2005/12/1, Afternoon <afte...@uk2.net>:
>
>
> On 1 Dec 2005, at 14:29, Paolo wrote:
>
> > [Thu Dec 01 11:07:13 2005] [notice] child pid 15299 exit signal
> > Segmentation fault (11)
>
> Ah, I spent a frustrating few hours wrestling with this error (or one
> like it) last night. Are you using mod_python 3? After building
> mod_python have you fully restarted Apache or just gracefully
> restarted it?

Hi Afternoon, not only I have restarted Apache after building
mod_python (3.1.4), I also have updated it from version 2.0.54 to
2.0.55, but nothing has changed.

Afternoon

unread,
Dec 1, 2005, 10:51:01 AM12/1/05
to django...@googlegroups.com

On 1 Dec 2005, at 15:24, Paolo wrote:

> Hi Afternoon, not only I have restarted Apache after building
> mod_python (3.1.4), I also have updated it from version 2.0.54 to
> 2.0.55, but nothing has changed.

Hang on, it's coming back to me now (sorry, it was a long night).

What platform are you building on? Where is your Python? I had to
define PYTHONHOME = /usr/ in envopts for Apache because I'm running
OS X and my Python is stock but my Apache comes from the Fink project.

Is there any way that Apache might not be able to find Python such as
this?

Paolo

unread,
Dec 1, 2005, 3:26:09 PM12/1/05
to django...@googlegroups.com
2005/12/1, Afternoon <afte...@uk2.net>:
>
> What platform are you building on? Where is your Python? I had to
> define PYTHONHOME = /usr/ in envopts for Apache because I'm running
> OS X and my Python is stock but my Apache comes from the Fink project.
>
> Is there any way that Apache might not be able to find Python such as
> this?

Well, my experiments take place on linux slackware, kernel 2.4.26.
Running a simple mod_python test handler, like the one to test if
mod_python installation has completed succesfully
(http://www.modpython.org/live/current/doc-html/inst-testing.html),
happens without problems. This make me think that
apache/mod_python/python installation is fine and that the problem is
in httpd.conf or in my project.

So I'll post them. This is the relevant part of httpd.conf:
<VirtualHost 192.168.0.68:85>
DocumentRoot /home/paolo/projects/django
<Location /admin/>
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonPath ['/home/paolo/projects/django']+sys.path
SetEnv DJANGO_SETTINGS_MODULE cardano.settings
</Location>
</VirtualHost>

and this is urlpatterns:
urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls.admin')),
)

Project cardano lives in /home/paolo/projects/django

Thanks

Afternoon

unread,
Dec 1, 2005, 3:59:11 PM12/1/05
to django...@googlegroups.com

> This make me think that
> apache/mod_python/python installation is fine and that the problem is
> in httpd.conf or in my project.

The fact that the child process is dying suggests something fairly
low-level, but if you have another MP handler that works OK that's a
bit strange. I always had either one or the other. Although I confess
I didn't test another handler, I did start getting stack traces when
I fixed a few bits.

Have you tried adding PythonDebug On to your httpd.conf? Also, I'm
using SetHandler python-program, no idea if that makes any difference
though.

Bryan Murdock

unread,
Dec 1, 2005, 4:04:29 PM12/1/05
to django...@googlegroups.com
On 12/1/05, Paolo <paol...@gmail.com> wrote:
>
> I'm trying to setup Django with Apache and mod_python.
>
> I have followed the procedure described in the document "how to use
> Django with mod_python", but I can't obtain a working basic (single
> Django installation on the same Apache) environment, because Apache
> unexpectedly crashes at each request.

Do you have mod_php running too? See this:

http://www.modpython.org/pipermail/mod_python/2004-January/014886.html

Bryan

frank h.

unread,
Dec 2, 2005, 2:21:08 AM12/2/05
to Django users
hej paolo,
I am on OS X as well, and I had problems with Apache and mod_python.
Turns out that my python (version 2.4.1 from fink) was the problem.

the following worked for me:

stop any apache that is currently running (fink or buildin)

install python 2.4.1 framework build from http://undefined.org/python/
(you might need to install the Tiger patch as well)

set /usr/local/bin as first in $PATH

install apache2:
curl -O http://www.apache.org/dist/httpd/httpd-2.0.55.tar.gz
tar xvfz httpd-2.0.55.tar.gz
cd httpd-2.0.55
./configure --enable-so --with-mpm=worker
make
sudo make install

install mod_python:
curl -O http://www.apache.org/dist/httpd/modpython/mod_python-3.1.4.tgz
tar xvfz mod_python-3.1.4.tgz
cd mod_python-3.1.4
./configure --with-apxs=/usr/local/apache2/bin/apxs
--with-python=/usr/local/bin/python
make
sudo make install

sudo edit /usr/local/apache2/conf/httpd.conf
>LoadModule python_module /usr/local/apache2/modules/mod_python.so

then follow the instructions here
http://www.djangoproject.com/documentation/modpython/ or
here http://cavedoni.com/2005/django-osx to configure django

then start the new apache2 install (check
/usr/local/apache2/logs/error_log)
sudo /usr/local/apache2/bin/apachectl start

well, this worked for me on 10.3 and 10.4
hope it helps
Frank

Paolo

unread,
Dec 2, 2005, 8:45:44 AM12/2/05
to django...@googlegroups.com
2005/12/1, Afternoon <afte...@uk2.net>:
> Have you tried adding PythonDebug On to your httpd.conf? Also, I'm
> using SetHandler python-program, no idea if that makes any difference
> though.

Yes, PythonDebug is On, and to increase verbosity LogLevel is set to
value debug.

For mod_python 3.1, it is preferred to use mod_python, as
python-program is the old name (that is still supported). With
mod_python 2.7 instead it is mandatory to use python-program.

Paolo

unread,
Dec 2, 2005, 8:56:03 AM12/2/05
to django...@googlegroups.com
2005/12/1, Bryan Murdock <bmur...@gmail.com>:

> Do you have mod_php running too? See this:
>
> http://www.modpython.org/pipermail/mod_python/2004-January/014886.html

No mod_php installed! I already checked that (and this faq gives an
explanation about mod_php and mod_python incompatibilities in some
circumstances, http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp)

>
> Bryan

Thanks

Paolo

unread,
Dec 2, 2005, 9:27:59 AM12/2/05
to django...@googlegroups.com
2005/12/2, frank h. <frank.ho...@gmail.com>:
>
> hej paolo,
> I am on OS X as well, and I had problems with Apache and mod_python.

Hi frank, I'm not running OS X! I looked at django's documentation and
at http://cavedoni.com/2005/django-osx, as you suggested, but even
trying a bunch of different "variations", I've not yet achieved a
working setup. In the meanwhile I'm asking to mod_python's people.

Thanks for help
Reply all
Reply to author
Forward
0 new messages