This was a bit tricky, so I thought I would document my experience. First off you need to install libapache2-mod-wsgi
. Then use an apache config like this
WSGIDaemonProcess join processes=30 threads=1 maximum-requests=10000 python-path=/full_path_to/my_django
WSGIProcessGroup join
WSGIRestrictStdout Off
<Directory /full_path_to/my_django/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory {{app_path}}/static>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName host_name
ServerAlias www.whatever.com
Alias /static /full_path_to/my_django/static
WSGIScriptAlias / /full_path_to/my_django/mysite/wsgi.py
</VirtualHost>
<VirtualHost *:443>
ServerName host_name
ServerAlias www.whatever.com
Alias /static /full_path_to/my_django/static
WSGIScriptAlias / /full_path_to/my_django/mysite/wsgi.py
</VirtualHost>
Note the python-path
included so it doesn't choke on your settings in wsgi.py. In your settings.py you need a few things
# debug false or it compiles assets on the fly
DEBUG = False
# set allowed host, * covers everything, but you should set this specifically
ALLOWED_HOSTS = ['*']
# static files settings
STATIC_URL = '/static/'
STATICFILES_DIRS = ['assets']
STATIC_ROOT = 'static'
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
And your wsgi.py should be simple like this
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
You'll have to run your collect static on the server to generate assets
python /full_path_to/my_django/manage.py collectstatic