Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active January 6, 2024 15:06
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save springmeyer/3427021 to your computer and use it in GitHub Desktop.
Save springmeyer/3427021 to your computer and use it in GitHub Desktop.
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/
@cappelaere
Copy link

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)

@springmeyer
Copy link
Author

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

@radzhome
Copy link

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.

@antonakv
Copy link

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
Copy link

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?

@JulieGoldberg
Copy link

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