This guide walks you through the setup for running GeoKey in Apache using mod_wsgi
. We assume that you have already installed GeoKey.
sudo apt-get install apache2 libapache2-mod-wsgi
We now create directories that are used to serve static files like images, CSS and JavaScript, also media uploaded by users.
Head to Apache www directory
cd /var/www
Create a directory for GeoKey specific files
sudo mkdir geokey
Create directories for static files and assets uploaded by users
sudo mkdir geokey/static
sudo mkdir geokey/media
Open your local_settings.py
, e.g.
sudo vim /home/django/runner/local_settings.py
Add or change settings for static
and media
STATIC_ROOT = '/var/www/geokey/static/'
STATIC_URL = '/static/'
MEDIA_ROOT = '/var/www/geokey/media/'
MEDIA_URL = '/media/'
Collect static files from the Python packages (they will be automatically stored under /var/www/geokey/static/
)
cd /home/django/runner
python manage.py collectstatic
Depending on your user role, you might need to add temporarily writing permission to /var/www/geokey/static/
.
Finally, allow Apache to write to you media directory
chgrp -R www-data /var/www/geokey/media/
chmod -R 775 /var/www/geokey/media/
We are going to use the default virtual host provided by the Apache installation. The same configuration can be applied to other virtual hosts on your system.
Open the Apache configuration file in your text editor (we use vim, because itβs awesome):
vim /etc/apache2/sites-available/000-default.conf
Add the following lines just below <VirtualHost *:80>
:
WSGIDaemonProcess geokey python-path=/home/django:/home/django/env/lib/python2.7/site-packages
WSGIProcessGroup geokey
WSGIScriptAlias / /home/django/wsgi.py
WSGIPassAuthorization On
This first line creates a new WSGI daemon that runs GeoKey in Apache. Its name (in our case geokey
) can be anything, but you should use a descriptive name. The python-path
directive contains both the path of your Django project and the path to the Python packages inside your virtual environment.
The third line tells the virtual host to use the WSGI daemon we just created.
The fourth line tells Apache and mod_wsgi where to find the WSGI configuration.
The last line enables WSGI to pass authorisation credentials to the Django application. This is necessary, because Django would not be able to authenticate users otherwise.
We then have to tell Apache where to find static and media files from your Django project (temember, we previously created these directories and copied the static files)
Alias /static/ /var/www/geokey/static/
<Location "/static/">
Options -Indexes
</Location>
Alias /media/ /var/www/geokey/media/
<Location "/media/">
Options -Indexes
</Location>
To tell WSGI where to find configuration files for our Django project, open the WSGI configuration in your text editor
sudo vim /home/django/runner/wsgi.py
Add following line just below from django.core.wsgi import get_wsgi_application
import sys
sys.path.append('/home/django/runner')
Now restart the Apache
sudo service apache2 restart
Point your browser to your domain. You should see the admin landing page now.
Videos are β by default β uploaded to your YouTube account.
You will need to obtain YouTube API keys following this guide.
Set the ENABLE_VIDEO
flag in local_settings
:
ENABLE_VIDEO = True
The add the credentials to local_settings
:
YOUTUBE_AUTH_EMAIL = 'your-email@example.com'
YOUTUBE_AUTH_PASSWORD = 'password'
YOUTUBE_DEVELOPER_KEY = 'xxxxxxxxxxx'
YOUTUBE_CLIENT_ID = 'xxxxxxxxxxx.apps.googleusercontent.com'
GeoKey uses email in various cases; for instance, when users want to reset their password. We therefore need to setup Postfix to send email from your server.
First install Postfix
apt-get update && apt-get install postfix
Add a default email address that is used as sender for e-ails send by Django in local_settings
DEFAULT_FROM_EMAIL = 'sender@example.com'