I'm looking to follow a recipe, using mod_wsgi for two purposes:
- To have a dev server running via apache, to integrate PHP and SSL components, as well as having "hot code replacement" to support development.
- To evaluate mod_wsgi on the basis of the claim: "for hosting WSGI applications in conjunction with Apache it has a lower memory overhead and performs better than mod_python".
Step 1 will be to deploying using mod_wsgi on my dev laptop per the mod_wsgi docs.
- sudo apt-get install libapache2-mod-wsgi [ubuntu]
- restart apache
- create appropriate .wsgi file
- edit apache.conf with directive (see below)
Step 4, finally per: http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html, is to add a monitor.py (the source of which is here) and reference it in the .wsgi file.
Here are example apache / httpd.conf:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for the deamon behavoir | |
WSGIDaemonProcess appname-django processes=2 threads=15 | |
WSGIProcessGroup appname-django | |
NameVirtualHost *:80 | |
<VirtualHost *:80> | |
ServerName www.client1.net | |
# to mount the application from the wsgi script (see next gist) | |
WSGIScriptAlias / /path/to/your/dev.wsgi | |
Alias /media/ /path/to/your/django/media/ | |
<Directory /path/to/your/django/media/> | |
Order deny,allow | |
Allow from all | |
</Directory> | |
</VirtualHost> |
And dev.wsgi (based of putting a monitor.py in the root of the django app):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
sys.path.append('/path/to/djangoapp/') | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoapp.settings' | |
import django.core.handlers.wsgi | |
application = django.core.handlers.wsgi.WSGIHandler() | |
import djangoapp.monitor | |
djangoapp.monitor.start(interval=1.0) | |
No comments:
Post a Comment