Skip to content

Instantly share code, notes, and snippets.

@stevage
Forked from springmeyer/install-tilemill-latest.sh
Last active December 22, 2015 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevage/6461449 to your computer and use it in GitHub Desktop.
Save stevage/6461449 to your computer and use it in GitHub Desktop.
Updated version to function more like proper bash scripts. (The 'sudo su postgres' stuff didn't work properly.)
#!/bin/bash
# First, clear out any old mapnik or node.js installs that might conflict
sudo apt-get purge libmapnik libmapnik-dev mapnik-utils nodejs
# Also clear out any old ppa's that might conflict
sudo rm /etc/apt/sources.list.d/*mapnik*
sudo rm /etc/apt/sources.list.d/*developmentseed*
sudo rm /etc/apt/sources.list.d/*chris-lea*
# add new ppa's
echo 'yes' | sudo apt-add-repository ppa:chris-lea/node.js
echo 'yes' | sudo apt-add-repository ppa:mapnik/v2.2.0
# update
sudo apt-get -y update
sudo apt-get -y upgrade
# install nodejs latest and a few tilemill deps
sudo apt-get install -y nodejs git build-essential libgtk2.0-dev \
libwebkitgtk-dev protobuf-compiler libprotobuf-lite7 libprotobuf-dev \
libgdal1-dev
# Now, either install mapnik latest from packages
# Alternatively (uncomment, and comment out the mapnik-utils line):
# ./mapnik-from-source.sh
sudo apt-get install -y libmapnik-dev mapnik-utils
# set up postgres
export POSTGRES_VERSION=9.1 # you may need to change this depending on ubuntu version
export POSTGIS_VERSION="1.5" # you may need to change this depending on ubuntu version
export POSTGRES_USER=ubuntu # change if desired
sudo apt-get install -y postgresql postgresql-server-dev-$POSTGRES_VERSION postgresql-$POSTGRES_VERSION-postgis
sudo -Eu postgres -s <<"EOF"
createuser -s $POSTGRES_USER
createdb template_postgis
createlang -d template_postgis plpgsql # you may not need this
POSTGIS_PATH=`pg_config --sharedir`/contrib/postgis-$POSTGIS_VERSION
psql -d template_postgis -f $POSTGIS_PATH/postgis.sql
psql -d template_postgis -f $POSTGIS_PATH/spatial_ref_sys.sql
EOF
# build tilemill
git clone https://github.com/mapbox/tilemill.git
cd tilemill
npm install
# then start it...
# if you are running a desktop server then just boot using all the defaults
./index.js # should open a window automatically, but you can also view at http://localhost:20009
# if you are running a headless/remote server then you can connect either
# by ssh connection forwarding or by opening up public access to the machine.
# for details on ssh forwarding see http://www.mapbox.com/
# Installing Mapnik from source
# See https://github.com/mapnik/mapnik/wiki/UbuntuInstallation for more details
sudo apt-get install -y wget subversion
# Or, install proj4 latest and then mapnik from source:
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
# we use trunk instead for better threading support
svn co http://svn.osgeo.org/metacrs/proj/trunk/proj proj-trunk # at the time pre-release 4.8.0
cd proj-trunk/nad
unzip -o ../../proj-datumgrid-1.5.zip
cd ../
./configure
make
make install
# grab boost PPA for recent enough version
sudo add-apt-repository ppa:mapnik/boost
sudo apt-get update
sudo apt-get install -y libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev
# mapnik dev deps
sudo apt-get install -y g++ cpp \
libicu-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-python-dev libboost-regex-dev \
libboost-system-dev libboost-thread-dev \
python-dev libxml2 libxml2-dev \
libfreetype6 libfreetype6-dev \
libjpeg-dev \
libltdl7 libltdl-dev \
libpng-dev \
libproj-dev \
libgeotiff-dev libtiff-dev libtiffxx0c2 \
libcairo2 libcairo2-dev python-cairo python-cairo-dev \
libcairomm-1.0-1 libcairomm-1.0-dev \
ttf-unifont ttf-dejavu ttf-dejavu-core ttf-dejavu-extra \
git build-essential python-nose clang \
libgdal1-dev python-gdal \
postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-9.1-postgis \
libsqlite3-dev
# mapnik sources
git clone http://github.com/mapnik/mapnik
cd mapnik
./configure
make && sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment