Please help, strange errors crashing my site

58 views
Skip to first unread message

peon...@gmail.com

unread,
Apr 24, 2007, 2:15:49 AM4/24/07
to Django users
Hi,

I have a django site that just launched using mod_python, apache2, and
redhat. It's a medium sized site, everything worked great for a couple
days, yesterday I suddenly got error after error in my apache logs
such as the ones below. This happens even though there are no code
changes. The site stays down until I restart reload apache and the
site works again. But today the site went down and I got very similar
errors. The old site used to have different urls, could people/bots
trying to retrieve old urls be confusing django?

Thanks, any help would be greatly appreciated,

Leon

[Mon Apr 23 19:09:18 2007] [error] [client 66.249.65.230]
PythonHandler django.core.handlers.modpython: ExtractionError: Can't
extract file(s) to egg cache\n\nThe following error occurred while
trying to extract file(s) to the Python egg\ncache:\n\n [Errno 13]
Permission denied: '/.python-eggs'\n\nThe Python egg cache directory
is currently set to:\n\n /.python-eggs\n\nPerhaps your account does
not have write access to this directory? You can\nchange the cache
directory by setting the PYTHON_EGG_CACHE environment\nvariable to
point to an accessible directory.\n

[Mon Apr 23 19:11:31 2007] [error] [client 24.215.224.50]
PythonHandler django.core.handlers.modpython: File "/usr/lib/
python2.3/site-packages/django/core/handlers/base.py", line 35, in
load_middleware\n raise exceptions.ImproperlyConfigured,
'Middleware module "%s" does not define a "%s" class' % (mw_module,
mw_classname)
[Mon Apr 23 19:11:31 2007] [error] [client 24.215.224.50]
PythonHandler django.core.handlers.modpython: ImproperlyConfigured:
Middleware module "django.contrib.sessions.middleware" does not define
a "SessionMiddleware" class

Graham Dumpleton

unread,
Apr 24, 2007, 7:50:32 AM4/24/07
to Django users
Stupid Google groups seems to have trashed my last response, now I
have to type it all in again. Apologies if this is a duplicate.

Anyway, for one explanation, see description on access rights of
Apache user in mod_wsgi documentation at:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues

Although not mod_python the issue is exactly the same.

In mod_python, only practical way of solving it without modifying
Apache startup scripts is to use PythonImport directive to reference
module containing:

import os
os.environ['PYTHON_EGG_CACHE'] = '/some/directory'

Where '/some/directory' is writable to user that Apache runs as.

When using PythonImport you need to name the Python interpreter that
your Django application is running in, usually the name of the
VirtualHost under mod_python. If you can't work it out, use
PythonInterpreter to explicitly name what interpreter you want Django
instance to use and use same name with PythonImport. See mod_python
documentation for more details on these directives.

Graham

Graham Dumpleton

unread,
Apr 24, 2007, 7:42:42 AM4/24/07
to Django users
Both mod_wsgi and TurboGears contain specific notes about this issue
with Python eggs when using Python running inside of Apache.

In mod_wsgi documentation read section on 'Access Rights Of Apache
User' in:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues

In TurboGears documentation read section headed 'The general stuff'
in:

http://docs.turbogears.org/1.0/mod_python

When using mod_python as you are, probably the only way to get around
the problem without changing the startup scripts for Apache is to use
the mod_python PythonImport directive to import, at startup of each
Apache child process, into the same Python interpreter as your Django
application is running, a module which sets the PYTHON_EGG_CACHE
environment variable. Ie., the module imported using PythonImport
should say:

import os
os.environ['PYTHON_EGG_CACHE'] = '/some/directory'

Where '/some/directory' is a directory writable by the user that
Apache runs as.

Graham

On Apr 24, 4:15 pm, peonl...@gmail.com wrote:

> Hi,
>
> I have a django site that just launched usingmod_python, apache2, and

Reply all
Reply to author
Forward
0 new messages