This is how I do it on my Mac, with Apache, Python and Django from Mac ports. This is not necessarily the best approach, but it works for me.
I have the following top level directories:
lib: python code with settings.py parameters in the lib / settings.py folderstatic: material that Apache should serve, for example. Media and CSS.tools: development tools, for example. deployment scenarios.
So, here's the Apache config for an example site, and then see the Django WSGI script below:
<VirtualHost *:80>
DocumentRoot /Library/WebServer/mysite/static
ServerName mysite.local
RewriteEngine on
RewriteRule ^/$ /mysite/ [R,L]
Alias /static/ /Library/WebServer/mysite/static/
<Directory "/Library/WebServer/mysite/static/">
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess mysite-django.local processes=1 threads=5 maximum-requests=0 display-name=%{GROUP} python-path=/Library/WebServer/mysite/lib python-eggs=/tmp
WSGIProcessGroup mysite-django.local
WSGIScriptAlias / /Library/WebServer/mysite/lib/apache/django_wsgi.py
<Directory "/Library/WebServer/mysite/lib/apache">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Django WGCI script is located in lib / apache / django_wsgi.py:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
source
share