Help How to install on Ubuntu

Navigate

    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.

    This guide shows you how to install GeoKey on a Ubuntu machine. We have prepared installation guides for the following additional systems:

    Installing pre-requisites

    1. Update your system

       sudo apt-get update && sudo apt-get upgrade
      
    2. Install Postgres and PostGIS (we follow the official guides)

      sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt trusty-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 pgadmin3

    3. 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

    4. 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

    Setting up the database

    1. Create a new user on you system, which GeoKey uses to write to and read from the data base

      # adduser django

    2. 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';

    3. Create the database

      CREATE DATABASE geokey OWNER django;

      Close the data base connection

      \q

    4. Install the PostGIS extension on you database

      psql -d geokey -c 'create extension postgis;'

      psql -d geokey -c 'create extension hstore;'

    5. Finally log out

      logout

    Setting up your virtual environment

    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.

    1. Choose a directory where you have write access and create an empty virtual environment

      virtualenv env

    2. Activate the env

      source env/bin/activate

    3. Upgrade pip so the correct python dependencies will be installed later on

      pip install --upgrade pip

    Setting up GeoKey

    1. Install the package

      pip install geokey

    2. Download and unzip the GeoKey runner:

      wget http://geokey.org.uk/downloads/settings.tar.gz

      tar -xvf settings.tar.gz

    3. 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'

    4. Create the database structure

      python manage.py migrate

    5. Add yourself as superuser

      python manage.py createsuperuser

    6. 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.