Set up Tilemill on Ubuntu 12.04
and the OSM bright stylesheet
and postgres/postgis
and imposm
and import OpenStreetMap data for the Isle of Wight (it's fairly small so it'll import quickly)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on http://www.mapbox.com/tilemill/docs/guides/osm-bright-ubuntu-quickstart/ | |
sudo add-apt-repository --yes ppa:developmentseed/mapbox | |
sudo apt-get update | |
sudo apt-get --yes install tilemill libmapnik nodejs postgresql postgresql-9.1-postgis build-essential python-dev protobuf-compiler libprotobuf-dev libtokyocabinet-dev python-psycopg2 libgeos-c1 python-pip git | |
sudo pip install imposm | |
mkdir osm | |
cd osm | |
# OPTIONAL Move postgres data directory onto EC2 ephemeral storage. | |
echo "--- /etc/postgresql/9.1/main/postgresql.conf 2013-07-25 11:59:03.000000000 +0000 | |
+++ /etc/postgresql/9.1/main/postgresql.conf 2013-07-25 12:03:08.817403077 +0000 | |
@@ -38,7 +38,8 @@ | |
# The default values of these variables are driven from the -D command-line | |
# option or PGDATA environment variable, represented here as ConfigDir. | |
-data_directory = '/var/lib/postgresql/9.1/main' # use data in another directory | |
+#data_directory = '/var/lib/postgresql/9.1/main' # use data in another directory | |
+data_directory = '/mnt/postgres-data' | |
# (change requires restart) | |
hba_file = '/etc/postgresql/9.1/main/pg_hba.conf' # host-based authentication file | |
# (change requires restart)" > postgresql.conf.diff | |
# UNCOMMENT THESE LINES if you want your postgres data on ephemeral storage: | |
#sudo cp -rp /var/lib/postgresql/9.1/main /mnt/postgres-data | |
#sudo patch /etc/postgresql/9.1/main/postgresql.conf < postgresql.conf.diff | |
# Allow postgres anonymous local login: | |
echo "--- /etc/postgresql/9.1/main/pg_hba.conf 2013-07-05 18:10:55.219538710 +0100 | |
+++ /etc/postgresql/9.1/main/pg_hba.conf 2013-07-05 18:15:13.558666437 +0100 | |
@@ -82,16 +82,16 @@ | |
# maintenance (custom daily cronjobs, replication, and similar tasks). | |
# | |
# Database administrative login by Unix domain socket | |
-local all postgres peer | |
+local all postgres trust | |
# TYPE DATABASE USER ADDRESS METHOD | |
# \"local\" is for Unix domain socket connections only | |
-local all all peer | |
+local all all trust | |
# IPv4 local connections: | |
-host all all 127.0.0.1/32 md5 | |
+host all all 127.0.0.1/32 trust | |
# IPv6 local connections: | |
-host all all ::1/128 md5 | |
+host all all ::1/128 trust | |
# Allow replication connections from localhost, by a user with the | |
# replication privilege. | |
#local replication postgres peer" > pg_hba.diff | |
sudo patch /etc/postgresql/9.1/main/pg_hba.conf < pg_hba.diff | |
sudo /etc/init.d/postgresql restart | |
psql -U postgres -c "create database osm;" | |
psql -U postgres -d osm -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql | |
psql -U postgres -d osm -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql | |
# Download and configure osm-bright style: | |
git clone https://github.com/mapbox/osm-bright.git | |
cp osm-bright/configure.py.sample osm-bright/configure.py | |
echo "--- configure.py 2013-07-05 18:11:40.804348839 +0100 | |
+++ configure.py 2013-07-05 18:25:43.313367483 +0100 | |
@@ -4,7 +4,7 @@ | |
from collections import defaultdict | |
config = defaultdict(defaultdict) | |
-config[\"importer\"] = \"osm2pgsql\" # either 'imposm' or 'osm2pgsql' | |
+config[\"importer\"] = \"imposm\" # either 'imposm' or 'osm2pgsql' | |
# The name given to the style. This is the name it will have in the TileMill | |
# project list, and a sanitized version will be used as the directory name | |
@@ -20,7 +20,7 @@ | |
config[\"postgis\"][\"host\"] = \"\" | |
config[\"postgis\"][\"port\"] = \"\" | |
config[\"postgis\"][\"dbname\"] = \"osm\" | |
-config[\"postgis\"][\"user\"] = \"\" | |
+config[\"postgis\"][\"user\"] = \"postgres\" | |
config[\"postgis\"][\"password\"] = \"\" | |
# Increase performance if you are only rendering a particular area by" > configure.diff | |
patch osm-bright/configure.py < configure.diff | |
# Download and import some map data (I chose the isle of wight for as it's small/fast to load) | |
wget http://download.geofabrik.de/europe/great-britain/england/isle-of-wight-latest.osm.pbf | |
imposm --connection postgis://postgres:@localhost/osm -m ./osm-bright/imposm-mapping.py --read --write --optimize --deploy-production-tables isle-of-wight-latest.osm.pbf | |
# One can run mapbox to create the user folder and import examples. | |
# Here we create it manually meaning you miss out on the example projects. | |
mkdir -p ~/Documents/MapBox/project | |
cd osm-bright | |
./make.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment