A month ago, I watched a DjangoCon 2012 presentation of Julien Phalip named Boosting teamwork with Vagrant. For those who are not familiar with Vagrant, it’s a tool that allows you to create and configure lightweight, reproducible and portable development environments. In the presentation, the case study #1 shows how he built a complete development environment for djangoproject.com. I found it very interesting that a user can setup itself and hence be ready very quickly to contribute to the project.
I’ve been wanted to try Vagrant for a while now and I thought it would be useful to build something similar for mapserver. To help the setup, I also decided to use Chef Solo, which is a tool that allows you to abstract definitions as source code to describe how you want each part of your infrastructure to be built. In my case, I wanted to automate the various configuration tasks rather than doing them by hands.
Before starting the tutorial, you might be interested in learning more about:
The goal was to get a complete development environment (Ubuntu precise 32bits) with all the following requirements:
- Configure and install mapserver (branch master, 6.2 and 6.0).
- Configure and build mapserver docs
- Configure mapserver msautotest
- Install Postgresql server, create DB, load msautotest DB data
- Install and configure web server
- Serve mapserver as cgi and fastcgi (All versions)
- Serve mapserver docs website
To setup these requirements, I’ve built a chef cookbook to take care of everything. You won’t have to configure the environment by hands. The tutorial has been tested on a Linux machine but should work properly on Windows and Mac with some adaptations.
You need the following softwares installed before doing the tutorial.
Ruby 1.9, Ruby Bundler and some module dependencies (libxslt, libxml2)
- For Windows, you can probably find binaries easily.
- For Mac, I would suggest that you use homebrew.
- On a Debian/Ubuntu machine, you can use the following command:
1 2 3
- Download the mapserver environment config files. This contains everything you need to make the development environment.
- Setup the ruby environment. This will install all needed ruby modules in the working directory.
- You might want to take a look at the Vagranfile and edit some config options:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
- Make the virtual environment. This will download, setup and install everything.
This step might take several minutes to complete.
When the setup is finished, you should have a complete development environment for the mapserver project.
Basic Vagrant commands:
Start the virtual machine:
bundle exec vagrant up
Stop the virtual machine:
bundle exec vagrant halt
Destroy the virtual machine:
bundle exec vagrant destroy
You can log in the machine with one of the following methods:
In the working directory of the environment:
bundle exec vagrant ssh
ssh (user: vagrant, pw: vagrant)
ssh -p 2202 vagrant@localhost
The source code of the different mapserver versions, mapserver doc and msautotest are in /home/vagrant/src.
You can run the msautotest with the usual
python run_test.pycommand. All tests should be succeeded, including postgresql/postgis ones.
You can rebuild the doc using
Mapserver executables are served by apache2:
- http://localhost:8002 points to the mapserver doc.
- http://localhost:8002/cgi-bin/mapserv points to mapserver master.
- http://localhost:8002/cgi-bin/mapserv-branch-6-0 points to mapserver branch 6.0.
- http://localhost:8002/cgi-bin/mapserv-branch-6-2 points to mapserver branch 6.2.
- You have also all the cgi-bin executables in fastCGI mode by appending “.fcgi” extension.
The chef mapserver dev cookbook is on github, feel free to contribute.
In the future versions of the chef mapserver dev cookbook, mapcache and tinyows will be added.