Setup development environment using Vagrant

Hiroshi Miura edited this page Jan 30, 2014 · 2 revisions

How to setup development server of OSM TileMan using Vagrant

Install Virtualbox or a other supported virtual machine software.

This installation manual uses Virtualbox on MacOS X as the development environment. https://www.virtualbox.org/

An author uses QEMU/KVM on Ubuntu 12.04.2(LTS) 64bit with PPA https://launchpad.net/~miurahr/+archive/vagrant

Install Vagrant

Download Vagrant and install it from http://downloads.vagrantup.com/ ( I used v1.4.3 at writing this article. )

Clone TileMan github repository

local% git clone https://github.com/osmfj/tileman.git
local% cd tileman

init repository as vagrant work directory

local% vagrant init

Edit Vagrantfile

Edit Vagrantfile for enabling port forwarding or adding your favorite conditions.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.provision :shell, :path => "bootstrap.sh"

  ## If you want to load test db and run test automatically, 
  ## enable a part of commented out.
  # config.vm.provision :shell, :path => "test/load.sh"
  # config.vm.provision :shell, :path => "test/run.sh"

  # please run:
  #  $ vagrant init
  #  $ vagrant box add precise64 <URL>
  #  $ vagrant up --provider=kvm  # if you use kvm
  #
  config.vm.provider :virtualbox do |vb, override|
   override.vm.box     = "precise64"
   override.vm.box_url = "http://files.vagrantup.com/precise64.box"
  end
  
  config.vm.provider :kvm do |kvm, override| 
    kvm.gui = true
    override.vm.box     = "precise64"
    override.vm.box_url = "https://s3-ap-northeast-1.amazonaws.com/miurahr-public/precise64-kvm.box"
  end

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. 
  # config.vm.network :forwarded_port, guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network :private_network, ip: "192.168.33.10"

end

Vagrant Up and provision

Type vagrant up command at the directory on cloned tileman directory where Vagrantfile exist.

local% vagrant up
[default] Importing base box 'precise64'...
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.2.8
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
…(snip)…
Processing triggers for man-db ...
Setting up m4 (1.4.16-2ubuntu1) ...
Setting up autoconf (2.68-1ubuntu2) ...
Setting up automake (1:1.11.3-1ubuntu2) ...
update-alternatives:
using /usr/bin/automake-1.11 to provide /usr/bin/automake (automake) in auto mode.

Setting up autopoint (0.18.1.1-5ubuntu3) ...
Setting up dh-autoreconf (5ubuntu1) ...
local%

The command will install Ubuntu with below tools:

  1. OpenResty(nginx)
  2. Mapnik
  3. Tirex
  4. TileMan

This process will take long time. Good timing for getting coffee ;)

Running nginx

Make TileMan enable and restart openresty/nginx

vagrant@precise64:$ sudo ln -s /etc/nginx/sites-available/tileman-proxy /etc/nginx/sites-enabled/tileman-proxy
vagrant@precise64:$ sudo service nginx reload

Test

You can access to the nginx process using port 8080 from your local machine as written in the rule in the Vagrantfile. And the TileMan server's VirtualHost is named 'tile'. So you have to add 'tile' entry on your local hosts file (not on the remote host).

local% sudo vi /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1  localhost tile
255.255.255.255  broadcasthost
::1             localhost
fe80::1%lo0  localhost

Finally, you can see tiles like this.

tile

Run as Tile generator Server

To make it working as tile generator server you need to load OSM database into PostGIS/PostgreSQL DBMS. You can use prepared load script for it.

local% vagrant ssh
local% cd /vagrant
local% test/load.sh

It loads Taiwan data for test(because size is relatively small and good for test purpose) It takes 10min or 1 hours for loading depending on your platform performance. (If you want to load japan data, it takes several hours, loading world takes several days)