Get Over the First Hump In Making Completely Custom, Beautiful Maps: Install Mapnik on Ubuntu


3 min read

As many of “you read earlier on this blog, we released Nice Map”: as a bridge for Drupal to better communicate with WMS servers. Jeff gave a nod to “NASA’s free server”:, which is a great source for beautiful surface imagery and an easy way to test WMS clients. However, the real benefit of mapping with WMS is that you can drop in any WMS-compliant server you like, and Nice Map and other clients will do the legwork of getting beautiful maps on your site. This opens up the possibility for completely custom, beautiful maps like we have on “Stumble Safely”: — maps that can set your site apart from the masses of Google Maps and match the zaniest color schemes. The level of flexibility offered by the WMS protocol and servers is an incredible boon for anyone doing online maps. Here’s one example of a custom map we built with this.


Luckily, there’s an open-source project, “Mapnik”: that makes building a WMS server into a matter of assembly rather than one of guesswork. In its earlier iterations, Mapnik gained a reputation for being a pain to install, but with the changes in 0.5 and up, it has become quite straightforward — dare I say, in some cases, easy. There are plenty of options for installing it: fastcgi, wsgi, TileCache, SVN or the packaged release, etc.

But if you’re using Mapnik in order to get a great WMS server, it’s nice to have an option with batteries included: this method puts all of the ingredients together: Mapnik, “lxml”: support for speed, “PostGIS”: compatibility, patches for a few common issues, and a mod_python server so that you can run it all on Apache.

First, I’ll go over the basic server requirements for this solution. Put simply, it’s great for Debian or Ubuntu systems on dedicated or virtual private servers. There are installation instructions for “Windows”: and “Macintosh”: on, but if you’re setting up a web server, Ubuntu is a great choice, and hosting companies like “Slicehost”: are making virtual private servers inexpensive, fast, and incredibly flexible. You’ll need about 140MB to build and install Mapnik if you don’t already have any of the required libraries and tools — in a fresh, minimal Ubuntu install, @[email protected] brings the installed packages to 123MB.

So assuming that you’ve got an Ubuntu server where you can use “sudo” to do operations with root privileges, installing Mapnik is mostly a snap. I’ll go over the quick method first.

  1. Get mapnik_matic by checking it out from our repository
  2. svn co [](
  3. Run the installation shell script with admin privileges*
  4. In Ubuntu 7.x,
  5. @sudo ./[email protected]
  6. In Ubuntu 8.x,
  7. @sudo ./[email protected]
  8. Edit @[email protected], changing the path @/home/tom/mapnik_matic/GIS/@ to the path to your GIS directory
  9. Set up Apache according to the file @sampleapache[email protected] If you’re using virtual hosts, you can simply edit the paths indicated in the file, copy it into sites-available, and linking this file to sites-enabled.
  10. Restart Apache and try it out.
  11. Note: This step, which includes compiling Mapnik from source, can take a very long time on SliceHost servers.

Here’s an example WMS request:


If you get a rendered image, rejoice! Your WMS server is ready to go and ready to hook up to great clients like "Nice Map": and "qgis":

Stay tuned for details on how to get Mapnik jiving with PostGIS!

A big "thanks to Troy at New America Foundation":, a long time Drupal user who financed some of our initial work with Mapnik. Please get in touch with us if you are doing cool things with Mapnik and have some functionality that you think we should know about. And please post patches to "Nice Map":

What we're doing.