About 4 years ago we wrote a post about setting up a map server with Mapnik and PostGIS. It’s still one of the most popular posts on the site but it’s VERY OLD. I wanted to update it with a slightly easier install method and some newer software. What’s in the stack? I’m glad you asked!
Unlike the previous guide, this one won’t cover basics of Linux and the command line. It’s also written for a Red Hat Enterprise Linux (RHEL) 7.2 server instead of Ubuntu. Let’s do it.
Provision the server
The first thing we need to do is provision a Red Hat Enterprise Linux server. Amazon EC2 is as good a place as any to do this, but feel free to use any server you’d like. A few things to keep in mind:
- You need at least 2GB of memory. On EC2, that’s a medium instance
- Make sure you open up at least port 22 so you can access the server via SSH. If you’d like, you can also open up port 5432 for remote Postgres access and 8000 (or anything you’d like) to access services you create via the web.
- If you are running this on EC2 and you create your PEM key to log into the server, don’t forget to
chmod 400to allow you to use it to login. Also, your username on EC2 is going to be
Login to the server via SSH
Once you’re all logged in, run a quick software update to make sure everything is up to date:
Great. We’re like 20% of the way there now. I told you this was going to be easy. Next step is to install Git and clone the install script:
Now change the permissions on the install script and execute it:
That’s it! Sit back and relax and pretend you’re Neo watching the matrix.
The install script
This script is pretty much a copy of Dane Springmeyer’s script for installing on a AWS instance. It sets up a few extra sources and installs all the necessary software. It also includes a few fixes specific to RHEL.
Testing the installation
While the install script was running, I hope you walked away to get a coffee and a snack. If so, you missed any error messages that might have appeared. Just in case there were some problems, let’s run a quick test.
If you did stick around, you may have noticed that the vector tile tests for node-mapnik failed so this installation won’t support vector tiles generation from Mapnik. If you’d like to investigate / fix the problem, please fork the Gist and I’ll update the post to point to yours. If you’d like to see the results of that test again run
npm-testfrom the node-mapnik directory.
For the tests, we’ll use the node-mapnik-sample-code. There are lots of tests and sample code, so it’s a good place to poke around once you’re up and running. First, clone the code onto the server:
Now install node-mapnik in that directory:
Now run the basic rendering code to use mapnik to generate a very simple map:
When you view the file (log onto your server using SFTP and download it), it should look something like this:
Success! You are now the proud owner of a map server. Go get another snack. You’ve earned it.
imagineRio - Rice University
Temporally and spatially accurate maps of Rio from 1500 to now