This guide walks you through the process of setting up GeoKey on your own server. It explains how to setup the database, how to install the Python packages and what configurations you should implement to make GeoKey run smoothly.
Update your system
sudo apt-get update && sudo apt-get upgrade
Install Postgres and PostGIS (we follow the official guides)
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt wheezy-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.4-postgis-2.1 postgresql-contrib postgresql-server-dev-9.4
Setup all other dependencies
sudo apt-get install python-pip python-virtualenv python-dev libjpeg-dev libmagickcore-dev libmagickwand-dev imagemagick binutils libproj-dev libav-tools gdal-bin python-gdal
Change ImageMagick permissions for it to be able to write:
sed -i 's/\(<policy domain="coder" rights=\)"none" \(pattern="PDF" \/>\)/\1"read|write"\2/g' /etc/ImageMagick-6/policy.xml
Create a new user on you system, which GeoKey uses to write to and read from the data base
# adduser django
Add the user to your database
Connect to PostgreSQL
# su - postgres
$ psql
Now you’re connected to PostgreSQL, you can add the user and create a new database, and to make it simple, we add ownership of that database to the user
CREATE USER django WITH PASSWORD 'django123';
Create the database
CREATE DATABASE geokey OWNER django;
Close the data base connection
\q
Install the PostGIS extension on you database
psql -d geokey -c 'create extension postgis;'
psql -d geokey -c 'create extension hstore;'
Finally log out
logout
We will install GeoKey in a virtual enviroment. That way you can run applications that depend on different versions of the same library simultaneously without having to worry about version conflicts.
Choose a directory where you have write access and create an empty virtual environment
virtualenv env
Activate the env
source env/bin/activate
Upgrade pip so the correct python dependencies will be installed later on
pip install --upgrade pip
Install the package
pip install geokey
Download and unzip the GeoKey runner:
wget http://geokey.org.uk/downloads/settings.tar.gz
tar -xvf settings.tar.gz
Open settings.py
and add the database info and a secret key to your app
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geokey',
'USER': 'django',
'PASSWORD': 'django123',
'HOST': 'localhost',
'PORT': '',
}
}
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Create the database structure
python manage.py migrate
Add yourself as superuser
python manage.py createsuperuser
You should be all set now, try running the test server
python manage.py runserver 0.0.0.0:8000
If you point your browser to your-domain.com:8000/admin
you should see the landing page of GeoKey.
Identify and fix troubles with your installation.
Now that you have installed GeoKey, learn how to make it available on the Web.