Skip to content

Instantly share code, notes, and snippets.

@Folcon
Forked from springmeyer/install-mapnik-amazon-ami.sh
Last active November 20, 2018 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Folcon/48561ca2999f014310a7bc71bdf7b3cd to your computer and use it in GitHub Desktop.
Save Folcon/48561ca2999f014310a7bc71bdf7b3cd to your computer and use it in GitHub Desktop.
Mapnik on Amazon Linux Default AMI (Fedora)
# http://aws.amazon.com/amazon-linux-ami/
# http://aws.amazon.com/amazon-linux-ami/faqs/
# Boot up a machine with at least 1.5 to 2 GB Ram
# login
chmod 600 key.pem
ssh -i key.pem ec2-user@ec2...compute.amazonaws.com
# update
sudo yum -y update
sudo yum -y upgrade
# enable EPEL6 by changing enabled=0 -> enabled=1
sudo vim /etc/yum.repos.d/epel.repo
# install deps
sudo yum -y install make gcc47 gcc-c++ bzip2-devel libpng-devel libtiff-devel zlib-devel libjpeg-devel libxml2-devel python-setuptools git-all python-nose python27-devel python27 proj-devel proj proj-epsg proj-nad freetype-devel freetype libicu-devel libicu
# install optional deps
sudo yum -y install gdal-devel gdal postgresql-devel sqlite-devel sqlite libcurl-devel libcurl cairo-devel cairo pycairo-devel pycairo
# install latest gcc
sudo yum -y install gcc72 gcc72-c++
# install harfbuzz
sudo yum install harfbuzz-0.9.20
JOBS=`grep -c ^processor /proc/cpuinfo`
# build recent boost
export BOOST_VERSION="1_68_0"
curl -L -O https://dl.bintray.com/boostorg/release/1.68.0/source/boost_${BOOST_VERSION}.tar.bz2
tar xf boost_${BOOST_VERSION}.tar.bz2
cd boost_${BOOST_VERSION}
./bootstrap.sh
./b2 -d1 -j${JOBS} \
--with-thread \
--with-filesystem \
--with-python \
--with-regex -sHAVE_ICU=1 \
--with-program_options \
--with-system \
link=shared \
release \
toolset=gcc \
stage
sudo ./b2 -j${JOBS} \
--with-thread \
--with-filesystem \
--with-python \
--with-regex -sHAVE_ICU=1 \
--with-program_options \
--with-system \
toolset=gcc \
link=shared \
release \
install
cd ../
# set up support for libraries installed in /usr/local/lib
sudo bash -c "echo '/usr/local/lib' > /etc/ld.so.conf.d/boost.conf"
sudo ldconfig
# harfbuzz
wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.3.0.tar.bz2
tar xf harfbuzz-1.3.0.tar.bz2
cd harfbuzz-1.3.0/
./configure --prefix=/usr --with-gobject
make
sudo make install
cd ..
# freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.6.tar.gz
tar -xzf freetype-2.6.tar.gz
cd freetype-2.6/
./configure --prefix=/usr --disable-static &&
make
sudo make install &&
sudo install -v -m755 -d /usr/share/doc/freetype-2.6.5 &&
sudo cp -v -R docs/* /usr/share/doc/freetype-2.6.5
sudo ldconfig
cd ..
# mapnik
git clone https://github.com/mapnik/mapnik
cd mapnik
git submodule update --init
python scons/scons.py CUSTOM_CXXFLAGS="-I/home/ec2-user/src/boost_${BOOST_VERSION}/" CUSTOM_LDFLAGS="-L/home/ec2-user/src/boost_${BOOST_VERSION}/libs"
make
make test-local
sudo make install
cd ..
# install protobuf libs needed by node-mapnik
sudo yum -y install protobuf-devel protobuf-lite
# Get version of npm (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 6.14.4
## check it works
node -e "console.log('Running Node.js ' + process.version)"
# If and only if you're getting Error: UNABLE_TO_GET_ISSUER_CERT_LOCALLY
sudo npm config set strict-ssl false
npm config set strict-ssl false
# node-mapnik
git clone https://github.com/mapnik/node-mapnik
cd node-mapnik
npm install
npm test
cd ../
# Don't forget to turn it back on if you turned it off earlier.
npm config set strict-ssl true
sudo npm config set strict-ssl true
# tileoven (previously tilemill)
git clone https://github.com/florianf/tileoven.git
cd tileoven
npm install sqlite3 gdal
vim package.json # remove the 'topcube' line since the GUI will not work on fedora due to lacking gtk/webkit
npm install
./index.js --server=true # view on http://localhost:20009
## To make it visible publically (careful with this)
TILEMILL_HOST="<aws public path>.compute.amazonaws.com" ./index.js --server=true --listenHost=0.0.0.0 --coreUrl=${TILEMILL_HOST}:20009 --tileUrl=${TILEMILL_HOST}:20008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment