Your OpenStreetMap server in 120GB

1. Install Ubuntu 14.04 server.
Remember to enable the firewall:
costales@maps:~$ sudo ufw allow http
costales@maps:~$ sudo ufw allow ssh
costales@maps:~$ sudo ufw enable

2. Check that you have all locales right:

costales@maps:~$ locale

If some of them are empty, add them to /etc/environment, in my case LC_ALL & LANGUAGE:

costales@maps:~$ cat /etc/environment

3. Install the server from a PPA:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:kakrueger/openstreetmap
sudo apt-get update
sudo apt-get install libapache2-mod-tile osmctools

4. Import a map: We'll drop so many data for allow the smallest database, then space in hard disk ;)
4.1 Download from here in pbf. For example, europe-latest.osm.pbf:
costales@maps:~$ wget

4.2 Do it small, we'll keep only the roads:
costales@maps:~$ osmconvert europe-latest.osm.pbf -o=europe.o5m
costales@maps:~$ osmfilter europe.o5m --drop-author --drop-version --keep="highway=cycleway" --keep="highway=path" --keep="highway=footway" --keep="highway=track" --keep="highway=service" --keep="highway=pedestrian" --keep="highway=unclassified" --keep="highway=residential" --keep="highway=tertiary" --keep="highway=secondary" --keep="highway=primary" --keep="highway=trunk" --keep="highway=motorway" --keep="highway=" --drop-tags="alt_name" --drop-tags="source" --drop-tags="maxspeed" --drop-tags="created_by" --drop-tags="wheelchair*" -o=europe_tmp.o5m
costales@maps:~$ osmconvert europe_tmp.o5m -o=europe_end.pbf
costales@maps:~$ rm europe-latest.osm.pbf europe.o5m europe_tmp.o5m

4.3 Import it into the database:
costales@maps:~$ osm2pgsql --drop --slim -C 1700 --number-processes 2 europe_end.pbf
1700 is the MB of RAM and 2 the CPUs.

5. Set it as complete and restart the service:
costales@maps:~$ touch /var/lib/mod_tile/planet-import-complete
costales@maps:~$ sudo /etc/init.d/renderd restart

6. It's done! Check it: http://localhost/osm/slippymap.html


  1. "1700 is the GB of RAM" Probably MB?

    1. Yeah, the man page says:

      "-C|--cache num
      Only for slim mode: Use up to num MB of RAM for caching nodes. Giving osm2pgsql sufficient cache to store all imported nodes typically greatly increases the speed of the import. Each cached node requires 8 bytes of cache, plus about 10% to 30% overhead. For a current OSM full planet import with its ~ 1.9 billion nodes, a good value would be 17000 if you have enough RAM. If you don't have enough RAM, it is likely beneficial to give osm2pgsql close to the full available amount of RAM. Without slim mode, there is also a "way" cache which takes up about as much space as the node cache does, but is not charged against -C. num defaults to 800."

  2. First of all, congratulation for the short tutorial.
    I would have a question about self updating server.

    If i want to make a self updating server, what would be the next steps ?

    1. Then, follow only the official doc ;)