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
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games”
LC_ALL=en_US.UTF-8
LANGUAGE=en_US.UTF-8
costales@maps:~$

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 https://download.geofabrik.de/europe-latest.osm.pbf

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