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.

I have a small with a minimum install of with about 256mb memory, it's newly installed with nothing special running on it. I'm trying to deploy to it, while I'm successfully running the server using manage.py, I can't get with working:

# service apache2 start && service apache2 status
* Starting web server apache2                      [ OK ] 
Apache is NOT running.

Erorr log /var/log/apache2/error.log:

[Thu Apr 14 21:17:29 2011] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Apr 14 21:17:29 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8 Python/2.6.5 configured -- resuming normal operations
[Thu Apr 14 21:17:29 2011] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Thu Apr 14 21:17:29 2011] [error] Exception KeyError: KeyError(-1216795792,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Thu Apr 14 21:17:29 2011] [alert] (11)Resource temporarily unavailable: apr_thread_create: unable to create worker thread
[Thu Apr 14 21:17:29 2011] [error] Exception KeyError: KeyError(-1216795792,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Thu Apr 14 21:17:31 2011] [alert] No active workers found... Apache is exiting!

My config file /etc/apache2/httpd.conf:

WSGIScriptAlias / /usr/local/django/deals/apache/django.wsgi

<Directory /usr/local/django/deals/apache>
Order deny,allow
Allow from all
</Directory>

The /usr/local/django/deals/apache/django.wsgi file:

import os
import sys

path = '/usr/local/django/deals'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'deals.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Seem to be installed:

# dpkg -l \*apache\* |grep -E '^ii'
ii  apache2                          2.2.14-5ubuntu8.4                        Apache HTTP Server metapackage
ii  apache2-mpm-worker               2.2.14-5ubuntu8.4                        Apache HTTP Server - high speed threaded mod
ii  apache2-utils                    2.2.14-5ubuntu8.4                        utility programs for webservers
ii  apache2.2-bin                    2.2.14-5ubuntu8.4                        Apache HTTP Server common binary files
ii  apache2.2-common                 2.2.14-5ubuntu8.4                        Apache HTTP Server common files
ii  libapache2-mod-wsgi              2.8-2ubuntu1                             Python WSGI adapter module for Apache
share|improve this question
    
Can you include the output of this command? dpkg -l \*apache\* |grep -E '^ii' –  chrishiestand Apr 15 '11 at 4:40
    
@dimmer - Added. :) –  Kit Sunde Apr 15 '11 at 8:01
add comment

2 Answers

up vote 2 down vote accepted

I finally figured out how to solve this. First of I trouble upgrading to from because the server only offered 128mb (256mb burstable) and ran out mid upgrade. Maybe the solution to this issue is to simply upgrade . I did however upgrade by installing it from source as described here, but that didn't seem to affect anything.

The breakthrough came when I installed through apt-get install apache2-mpm-prefork so it would use that instead of as dimmer suggested. I'm unsure if the issue was that having was causing my other errors not to be logged, maybe the next person who encounters issue can try skipping this step. When I switched to the error log gave the following errors instead.

 mod_wsgi (pid=1436): Exception occurred processing WSGI script '/usr/local/django/deals/apache/django.wsgi'.
 Traceback (most recent call last):
   File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/wsgi.py", line 250, in __call__
     self.load_middleware()
   File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
     for middleware_path in settings.MIDDLEWARE_CLASSES:
   File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/functional.py", line 276, in __getattr__
     self._setup()
   File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/conf/__init__.py", line 42, in _setup
     self._wrapped = Settings(settings_module)
   File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/conf/__init__.py", line 89, in __init__
     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
 ImportError: Could not import settings 'deals.settings' (Is it on sys.path?): No module named deals.setting

This is because we were unable to import the settings module. The wsgi integration with Django documentation explained that I need to add include paths, once I updated /usr/local/django/deals/apache/django.wsgi everything ran smoothly.

import os, sys

sys.path.append('/usr/local/django/deals')
sys.path.append('/usr/local/django')

os.environ['DJANGO_SETTINGS_MODULE'] = 'deals.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
share|improve this answer
add comment

That's an old mod_wsgi bug. Update mod_wsgi to a newer version.

share|improve this answer
1  
That would mean upgrading to ubuntu 10.10 - not a bad idea anyway if you can. Another option is to remove apache-mpm-worker and install apache2-mpm-prefork if you don't need threading. Apparently django is not entirely thread-safe and it's recommended you use prefork anyway. –  chrishiestand Apr 15 '11 at 8:24
    
After struggling with installing maverick on 256 mb burstable ram. I manually installed mod_wsgi from source via this: tiddlyspace.com/bags/cdent_public/tiddlers/Upgrading%20mod_wsgi but I'm getting the same error. Going to try dimmers suggestion next. –  Kit Sunde Apr 15 '11 at 16:17
add comment

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.