Installing Mapnik on CentOS 5

Instructions are provide at the mapnik website for installation on CentOS or Redhat. But unfortunately they are a little out of date and just didnt work for me. This guide provides the steps needed to install mapnik on CentOS 5.

Mapnik requires Python 2.5 or above and CentOS ships with 2.4 so first we will install python 2.6.  If you are running a 32 bit operating system you can download this repo file and place in /etc/yum.repos.d.

# wget http://mirrors.geekymedia.com/centos/geekymedia.repo
# mv geekymedia.repo /etc/yum.repos.d/
# yum install python26 python26-devel

But if you are running a 64 bit operating system python is going to need to be built from source. Download the latest version of python from here.

# wget http://www.python.org/ftp/python/2.6.5/Python-2.6.5.tgz
# tar zxvf Python-2.6.5.tgz
# cd Python-2.6.5
# ./configure
# make && make install

CentOS ships with boost, but is missing some components that mapnik will need. Because of this we will need to compile our own copy of boost. First install all of your dependencies

# yum install freetype-devel libtool-ltdl-devel libpng-devel libtiff-devel libjpeg-devel gcc-c++ libicu-devel bzip2-devel libxml2-devel

Now download the source code for boost from here

# wget http://downloads.sourceforge.net/project/boost/boost/1.43.0/boost_1_43_0.tar.gz
# tar zxvf boost_1_43_0.tar.gz
# cd boost_1_43_0
# ./bootstrap.sh

Before we can begin the build we need to point boost to Python 2.6. edit project-config.jam and edit this line:

# Python configuration
using python : 2.4 : /usr ;

to this:

# Python configuration
using python : 2.6 : /usr ;

Now we begin the build

# ./bjam

This can take quite a while to compile. So grab some coffee or read this

Once it is done compiling we need to add /usr/local/lib to our linker path and move boost to this directory

# cp -rfv stage/lib/* /usr/local/lib/
# cp -rf boost /usr/local/include
# vi /etc/ld.so.conf.d/local.conf
# /sbin/ldconfig

Next install PROJ.4 from source. Download here

# wget http://download.osgeo.org/proj/proj-4.7.0.tar.gz
# tar zxvf proj-4.7.0.tar.gz
# cd proj-4.7.0
# ./configure && make && make install

Now we need to download and compile mapnik. You can get the source from here

# wget http://download.berlios.de/mapnik/mapnik-0.7.1.tar.bz2
# bzip2 -d mapnik-0.7.1.tar.bz2
# tar xvf mapnik-0.7.1.tar
# cd mapnik-0.7.1
# python26 scons/scons.py configure
# python26 scons/scons.py install

And that’s it. You can test to ensure that it is properly installed with the following

# python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>>

If you do not get an error message you know you got everything right

3 Responses to “Installing Mapnik on CentOS 5”

  1. Andrew says:

    When I tried this I needed

    /usr/local/lib64
    /usr/local/lib

    in /etc/ld.so.conf.d/local.conf

  2. Mohammad says:

    Hi;

    I followed the above steps on an updated CentOS-5.5 (32-bit) …
    Every thing went on perfectly except the last step!
    When configuring Mapnik for installation (i.e. # python26 scons/scons.py configure) it says:
    “Boost version 1.34 or greater is requred”
    Why it can’t find the boost I have installed lately?! Am I missing something?!
    You can be sure that I followed every step above.

    Looking forward to your reply …

    Thanks in advance

  3. Raul says:

    After adding
    /usr/local/lib64
    /usr/local/lib
    to /etc/ld.so.conf.d/local.conf, you should execute
    /sbin/ldconfig

Leave a Reply

See also: