Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mapnik on Amazon Linux 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
JOBS=`grep -c ^processor /proc/cpuinfo`
# build recent boost
export BOOST_VERSION="1_55_0"
export S3_BASE="http://mapnik.s3.amazonaws.com/deps"
curl -O ${S3_BASE}/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
# mapnik
# stable branch: 2.3.x
git clone https://github.com/mapnik/mapnik -b 2.3.x
cd mapnik
./configure
make
make test-local
sudo make install
# node
NODE_VERSION="0.10.26"
wget http://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz
tar xf node-v${NODE_VERSION}.tar.gz
cd node-v${NODE_VERSION}
./configure
make -j${JOBS}
sudo make install
cd ../
# install protobuf libs needed by node-mapnik
sudo yum -y install protobuf-devel protobuf-lite
# Then workaround package bugs:
# 1) 'pkg-config protobuf --libs-only-L' misses -L/usr/lib64
# do this to fix:
export LDFLAGS="-L/usr/lib64"
# 2) '/usr/lib64/libprotobuf-lite.so' symlink is missing
# do this to fix:
sudo ln -s /usr/lib64/libprotobuf-lite.so.8 /usr/lib64/libprotobuf-lite.so
# otherwise you will hit: '/usr/bin/ld: cannot find -lprotobuf-lite' building node-mapnik
# node-mapnik
git clone https://github.com/mapnik/node-mapnik
cd node-mapnik
npm install
npm test
cd ../
# tilemill
git clone https://github.com/mapbox/tilemill
cd tilemill
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, more info: http://mapbox.com/tilemill/docs/guides/ubuntu-service/

The script is the best I've found in the web so far. Unfortunately, I'm still stuck building mapnik with the following cryptic gcc error:

g++ -o src/feature_style_processor.os -c -DHAVE_JPEG -DBIGINT -DBOOST_REGEX_HAS_ICU -ansi -Wall -pthread -ftemplate-depth-300 -DLINUX -DBOOST_SPIRIT_THREADSAFE -DMAPNIK_THREADSAFE -O3 -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts -DNDEBUG -DHAVE_CAIRO -fPIC -Ideps -Ideps/agg/include -I. -Iinclude -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/gdal -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 src/feature_style_processor.cpp
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See http://bugzilla.redhat.com/bugzilla for instructions.
scons: *** [src/feature_style_processor.os] Error 4
scons: building terminated because of errors.
make: *** [mapnik] Error 2

Owner

springmeyer commented May 23, 2013

@vramirez122000 - that indicates your machine does not have enough memory. You need >= 1.5 GB

You might also add that the .pem file must be "chmod 400 key.pem", otherwise you get the "unprotected private key file" error. Not sure if it's needed for these instructions, but it did stop me first :)

Owner

springmeyer commented Aug 2, 2013

@niklasbackman - that is a common thing yes, but outside the scope of this guide.

whyvez commented Mar 23, 2014

@springmeyer - when it cam time to build boost it complained about default command 'g++' not found. I had to install gcc-c++ in order for boost to build properly. Not sure if I did anything wrong or if something might have changed in the aws linux dist.

I'm not seeing python27 or gcc47 in epel -- are those provided by other repos? I'm running CentOS 6.5 and gcc 4.4.7/python 2.6.6 seem to work fine.

I couldn't get node-mapnik's npm test to work though mapnik/node-mapnik#247

OHSWEETJESUSTHANKYOU!!! I spent 48 hours trying to compile mapnik on centos 6-something but finally found your script. It seems to have worked.

Thanks again for this timely contribution.
But I am getting some errors testing Mapnik
*** Running python tests...
Notice: skipping postgis tests (connection)

.................................................................................................................................F...................................................................................................................................................................................................................................................................F........................F.......................................

FAIL: python_tests.image_filters_test.test_style_level_image_filter

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/ec2-user/mapnik/tests/python_tests/image_filters_test.py", line 64, in test_style_level_image_filter
eq_(len(fails), 0, '\n'+'\n'.join(fails))
AssertionError:
failed comparing actual (/tmp/mapnik-style-image-filter-none.png) and expected(tests/python_tests/images/style-image-filter/none.png)
failed comparing actual (/tmp/mapnik-style-image-filter-agg-stack-blur22.png) and expected(tests/python_tests/images/style-image-filter/agg-stack-blur22.png)
failed comparing actual (/tmp/mapnik-style-image-filter-blur.png) and expected(tests/python_tests/images/style-image-filter/blur.png)
failed comparing actual (/tmp/mapnik-style-image-filter-edge-detect.png) and expected(tests/python_tests/images/style-image-filter/edge-detect.png)
failed comparing actual (/tmp/mapnik-style-image-filter-emboss.png) and expected(tests/python_tests/images/style-image-filter/emboss.png)
failed comparing actual (/tmp/mapnik-style-image-filter-gray.png) and expected(tests/python_tests/images/style-image-filter/gray.png)
failed comparing actual (/tmp/mapnik-style-image-filter-invert.png) and expected(tests/python_tests/images/style-image-filter/invert.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sharpen.png) and expected(tests/python_tests/images/style-image-filter/sharpen.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sobel.png) and expected(tests/python_tests/images/style-image-filter/sobel.png)
failed comparing actual (/tmp/mapnik-style-image-filter-x-gradient.png) and expected(tests/python_tests/images/style-image-filter/x-gradient.png)
failed comparing actual (/tmp/mapnik-style-image-filter-y-gradient.png) and expected(tests/python_tests/images/style-image-filter/y-gradient.png)

FAIL: python_tests.raster_symbolizer_test.test_dataraster_query_point

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/ec2-user/mapnik/tests/python_tests/raster_symbolizer_test.py", line 73, in test_dataraster_query_point
assert len(features) == 1
AssertionError

FAIL: python_tests.render_test.test_render_with_scale_factor

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/ec2-user/mapnik/tests/python_tests/render_test.py", line 236, in test_render_with_scale_factor
eq_(actual.tostring(),expected.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/marker-text-line-scale-factor-1e-05.png) and expected (./images/support/marker-text-line-scale-factor-1e-05.png)


Ran 454 tests in 12.090s

FAILED (failures=3)

Owner

springmeyer commented Sep 3, 2014

Very minor test failures @cappelaere - I think you are good to go!

radzhome commented Jan 2, 2015

Doesn't install gdal on amazon linux 2014.09 , This is what happens:

--> Finished Dependency Resolution
Error: Package: gdal-libs-1.9.2-6.rhel6.x86_64 (pgdg93)
           Requires: libpoppler.so.5()(64bit)
Error: Package: gdal-java-1.9.2-6.rhel6.x86_64 (pgdg93)
           Requires: libpoppler.so.5()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

skip-broken doesn't fix the issue either. Any way to get gdal installed without compiling from source on the new Amazon Linux AMI? Its required for postgis running in AWS Elastic Beanstalk.

Any update here ?
I have the same issue with Amazon Linux AMI release 2015.03

---> Package gdal-libs.x86_64 0:1.9.2-6.rhel6 will be installed
--> Processing Dependency: libpoppler.so.5()(64bit) for package: gdal-libs-1.9.2-6.rhel6.x86_64
---> Package libquadmath.x86_64 0:4.8.2-16.2.99.amzn1 will be installed
--> Finished Dependency Resolution
Error: Package: gdal-libs-1.9.2-6.rhel6.x86_64 (pgdg94)
Requires: libpoppler.so.5()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

porjo commented Jul 16, 2016

Have tried this on latest Amazon Linux AMI but got various errors at the npm install stage. Can anyone confirm recent success with this script?

I'm using this as a guide to try an install on a CentOS 7 VM (not an Amazon box yet), and I can't get things to work. I'm skipping the boost stuff, because I can install boost with yum now. I only get warnings, not errors, on any installation, but when I run "npm test" in either tilemill (whose URL has to be updated) or in node-mapnik, I get the error that GLIBCXX_3.4.20 isn't found.

For what it's worth, I need the mapnik python bindings, and I don't care about using it from node. I think that I need this before I can install python-mapnik but I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment