I have a small vps with a minimum install of ubuntu lucid-lynx with about 256mb memory, it's newly installed with nothing special running on it. I'm trying to deploy django to it, while I'm successfully running the server using manage.py, I can't get apache with wsgi 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 apache 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
I finally figured out how to solve this. First of I trouble upgrading ubuntu to 10.10 from 10.04 because the server only offered 128mb (256mb burstable) and ran out mid upgrade. Maybe the solution to this issue is to simply upgrade ubuntu. I did however upgrade mod-wsgi by installing it from source as described here, but that didn't seem to affect anything.
The breakthrough came when I installed apache2-mpm-prefork through
apt-get install apache2-mpm-prefork
so it would use that instead of apache-mpm-worker as dimmer suggested. I'm unsure if the issue was that having apache-mpm-worker 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 apache-mpm-worker the apache error log gave the following errors instead.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.That's an old mod_wsgi bug. Update mod_wsgi to a newer version.