problem with threaded apache

2 views
Skip to first unread message

oggie rob

unread,
Apr 21, 2006, 1:06:28 AM4/21/06
to Django users
Hi all,
I have a problem with a new server that I am setting up.
Details are:
Fedora Core 5
apache httpd 2.2.0 (rpm)
postgresql 8.1.3 (rpm)
psycopg 1.1.21(source - and a real pain)
python 2.4 (rpm)
pretty weak hardware (800 mHz PIII, 256 M RAM)

So, this app runs fine on two other machines (similar Fedora setup and
a Windows one), runs with "runserver", runs when I use "httpd -X" on
this machine. Even runs when I set PythonDebug = True. The problem
comes about when I have apache running in it's regular multithreaded
mode. I see several errors, the root of which appears to be below, and
a 500 error on the page:

[Thu Apr 20 15:51:28 2006] [error] [client 10.116.59.53] PythonHandler
django.core.handlers.modpython: ImproperlyConfigured: Could not load
database backend: No module named psycopg. Is your DATABASE_ENGINE
setting (currently, 'postgresql') spelled correctly? Available options
are: 'ado_mssql', 'mysql', 'postgresql', 'sqlite3'

I tried patching with Eugene's fix for #1442, but that didn't seem to
solve the problem (after a httpd restart, anyway). I also confirmed
that my sys.path setting seems okay from the python shell.

Any ideas what I am facing here? Or how to debug this?

-rob

Jacob Kaplan-Moss

unread,
Apr 21, 2006, 9:03:53 AM4/21/06
to django...@googlegroups.com
On Apr 21, 2006, at 12:06 AM, oggie rob wrote:
> Any ideas what I am facing here? Or how to debug this?

I'd suggest switching to the "prefork" MPM for Apache; I've always
seen better performance and stability running Django under it as
opposed to the threaded one. Don't know if that's you're specific
issue, but everything else looks identical to our (working)
deployment architecture at work, so...

Jacob

Richie Hindle

unread,
Apr 21, 2006, 12:17:01 PM4/21/06
to django...@googlegroups.com

[Jacob]

> I'd suggest switching to the "prefork" MPM for Apache

For what it's worth, I think this advice should be in the documentation.
The documentation says "Apache with mod_python currently is the preferred
setup for using Django on a production server" but it doesn't explain
which MPM.

--
Richie Hindle
ric...@entrian.com


Dave St.Germain

unread,
Apr 21, 2006, 12:24:08 PM4/21/06
to django...@googlegroups.com
I've been running django (trunk and M-R) on apache prefork with no problems.  I recently switched to the worker MPM, and so far, everything seems to work fine (with better memory usage, I might add).  I did have a problem on a separate installation, however, related to memcache.  I think there may be a deadlock problem when using memcache and the worker MPM, but I haven't investigated it much yet.
But I can confirm that this combination works for me:
FreeBSD 6.0
Apache 2.0.55 with worker mpm
python 2.4.3
mod_python 3.2.8
psycopg 1.1.21
postgresql 8.1.3

Adrian Holovaty

unread,
Apr 21, 2006, 12:59:34 PM4/21/06
to django...@googlegroups.com
On 4/21/06, Richie Hindle <ric...@entrian.com> wrote:
> For what it's worth, I think this advice should be in the documentation.
> The documentation says "Apache with mod_python currently is the preferred
> setup for using Django on a production server" but it doesn't explain
> which MPM.

Good call. I've updated the docs.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

oggie rob

unread,
Apr 21, 2006, 1:41:05 PM4/21/06
to Django users
Thanks for the replies everybody. This is good info and I need to know
more about apache in general.

Unfortunately it doesn't solve the problem! I am using the vanilla
Fedora rpm for httpd which builds in prefork.c and has generally
default module directives. The funny behaviour is that it runs fine in
-X mode but doesn't run well with multiple forks. My mistake for naming
it multithreading, and sorry for not being clearer about that.

One difference I've found with my new server is that I am running
mod_python 3.2.8. On my old server I ran 3.1.4. I've also seen other
posts with people having similar problems, particularly on
http://www.djangoproject.com/documentation/modpython/

I started to rev back mod_python and ran into a few dependency
problems. I'll keep trying and see if that helps. Will let you know...

-rob

oggie rob

unread,
Apr 21, 2006, 3:47:39 PM4/21/06
to Django users
> I started to rev back mod_python and ran into a few dependency problems. I'll keep trying and see if that helps. Will let you know...

The REAL problem between my working (openhosting.com virtual) Fedora
system and this one was SELinux. Aarrgghh!

And of course I didn't have any problems in single user mode!

Thank you Yango for your comment on
http://www.djangoproject.com/documentation/modpython/

That's what I get for not using Red Hat for a few years... DDOS:
Dumbass Denial of Service

-rob

Vitaliy Fuks

unread,
Apr 21, 2006, 3:55:57 PM4/21/06
to Django users
Do you have SELinux enabled? Check /var/log/audit/audit.log and/or try
disabling it by editing /etc/sysconfig/selinux and rebooting.

oggie rob

unread,
Apr 21, 2006, 4:02:50 PM4/21/06
to Django users
Yes, I've disabled it now, and all is good!

Reply all
Reply to author
Forward
0 new messages