Installing open geo software from source: ubuntu edition

nvkelso edited this page Apr 24, 2013 · 29 revisions

(back to general Software section). Switch to the Mac version »

Assumes EC2 but run with it!

#Setting Up Ubuntu 11.10 (Oneiric) EC2 Instance

  1. Log in at console.aws.amazon.com

  2. Go to alestic.com and choose Ubuntu 11.10 Oneiric EBS boot (us-east-1)

  3. Choose instance type Medium and availability zone us-east-1d (or nearest you).

  4. Choose your keypair.

  5. Create a security group called custom_name.

    • We have opened ports 80, 22, 443, and 8133.
  6. Launch your instance

#Configure The EC2 Instance

  1. Log into the server with ssh -i /path/to/keypair ubuntu@<public-dns>

  2. sudo apt-get update

  3. sudo apt-get upgrade --fix-missing

  4. sudo apt-get install git --fix-missing

Install Prerequisites

sudo apt-get install -y build-essential python-software-properties software-properties-common

Install GDAL 1.9.1 (stable)

sudo add-apt-repository -y ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get install -y gdal-bin

You'll also likely want to install the python bindings for gdal and ogr:

sudo apt-get install -y python-gdal

Install Mapnik 2.1 (stable)

sudo add-apt-repository -y ppa:mapnik/v2.1.0 && sudo apt-get update
sudo apt-get install -y libmapnik

If you have large shapefiles (SHP) you'll also want to run shapeindex on them to significantly speed up map rendering:

sudo apt-get install mapnik-utils

Or install Mapnik 2.2 (nightly builds with expanded raster support)

sudo add-apt-repository -y ppa:mapnik/nightly-trunk && sudo apt-get update
sudo apt-get install -y libmapnik

Install TileStache

sudo apt-get install -y python-dev python-pip
sudo apt-get install -y python-cssutils python-imaging gunicorn python-mapnik
sudo apt-get install -y python-psycopg2 python-shapely
sudo pip install tilestache
sudo pip install cascadenik

Gotcha: If you later upgrade tilestache, it'll bork python-imaging (PIL). To fix:

sudo pip uninstall PIL

Shapely

Most basic operations (and a some super complex!) can be undertaken in Python using Shapely.

sudo apt-get install python-shapely

Fiona

When OGR is better, but is ugly. A better python interface for OGR (see above).

sudo apt-get install libgdal-dev
sudo pip install Fiona

osm2pgsql

sudo apt-get install -y osm2pgsql

Installing And Setting Up A PostGIS-Enabled PostgreSQL Database

  1. sudo apt-get install -y postgresql postgresql-contrib-9.1 postgresql-server-dev-9.1 postgresql-9.1-postgis

Make yourself a privileged user:

  1. sudo -u postgres createuser -s -d -r $USER

  2. Configure the postgres database

    Test you can log in to the database with:

    sudo -u postgres psql
    

    Background reading: https://help.ubuntu.com/11.10/serverguide/C/postgresql.html

    Confirm the following settings by editing the access permissions (or pico):

    sudo vim /etc/postgresql/9.1/main/pg_hba.conf 
    

    Made this section all have trust at the line ends:

    # Database administrative login by Unix domain socket
    local   all             postgres                                trust
    
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    local   all             all                                     trust
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    # Allow replication connections from localhost, by a user with the replication privilege.
    

    Then restart Postgres so that takes effect, if necessary:

    sudo /etc/init.d/postgresql restart
    
  3. Making Postgres fast

The defaults live in 1990s land. Upgrade your computer's gray matter!

  • Give Postgres more system memory, lots! - More is better here, set to the total RAM on your machine.
  • PGTune: Postgres config file: set the shared ram for each worker to ~2 to 4 gigs, depending on your setup. More (4 gb) is better unless you're running multiple concurrent sessions and need to play nice (2 gb).
  1. Set up your PostGIS template

    Read: https://github.com/nvkelso/geo-how-to/wiki/PostGIS

    Alternatively: http://wygoda.net/blog/postgis-template-database-ubuntu-1110/