Skip to content

Install Rendering (Ubuntu 18.04)

Jonathan Beliën edited this page Jan 22, 2019 · 13 revisions

The purpose to this server is to render tiles.
The tiles for https://tile.osm.be/ are streamed by another server.

Based on https://switch2osm.org/manually-building-a-tile-server-18-04-lts/

Requirements

  • Server with at least 30Go RAM
  • Server with at least 8 (v)CPU
  • Ubuntu 18.04 (obviously)

Update operating system

Just to be sure everything is up to date :

sudo apt-get update
sudo apt-get dist-upgrade

And restart your server :

sudo reboot

Install

Install required softwares and libraries

sudo apt-get install build-essential git cmake autoconf protobuf-c-compiler
sudo apt-get install libmapnik-dev mapnik-utils python-mapnik
sudo apt-get install gdal-bin
sudo apt-get install apache2
sudo apt-get install fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont
sudo apt-get install \
    libprotobuf-c0-dev zlib1g-dev libexpat1-dev libbz2-dev \
    libproj-dev liblua5.3-dev libboost-all-dev libpq-dev apache2-dev

Install NodeJS & CartoCSS (Mapnik Stylesheet Compiler)

sudo apt-get install npm nodejs
sudo npm install -g carto

Test:

$ carto -v
carto 1.1.0

Install renderd

mkdir ~/src && cd ~/src
git clone git://github.com/SomeoneElseOSM/mod_tile.git
cd mod_tile
./autogen.sh
./configure
make
sudo make install
sudo make install-mod_tile
sudo ldconfig
sudo mkdir /var/lib/mod_tile
sudo chown $USER /var/lib/mod_tile

sudo mkdir /var/run/renderd
sudo chown $USER /var/run/renderd

Update Apache configuration :

Create /etc/apache2/mods-available/mod_tile.load :

LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so

Edit /etc/apache2/sites-available/000-default.conf :

LoadTileConfigFile /usr/local/etc/renderd.conf
ModTileRenderdSocketName /var/run/renderd/renderd.sock
# Timeout before giving up for a tile to be rendered
ModTileRequestTimeout 0
# Timeout before giving up for a tile to be rendered that is otherwise missing
ModTileMissingRequestTimeout 300

Enable mod_tile and restart :

sudo a2enmod mod_tile
sudo service apache2 reload
sudo service apache2 reload

Update renderd configuration file :

Update needed parameters :

Edit /usr/local/etc/renderd.conf :

  • num_threads : should match the number of (v)CPU
  • plugins_dir : use mapnik-config --input-plugins to get the directory where Mapnik plugins are stored

Add following to /usr/local/etc/renderd.conf :

[osmbe]
URI=/osmbe/
TILEDIR=/var/lib/mod_tile
XML=/home/ubuntu/src/openstreetmap-carto-be/mapnik.xml
HOST=localhost
TILESIZE=256
MAXZOOM=18
CORS=*

[osmbe-fr]
URI=/osmbe-fr/
TILEDIR=/var/lib/mod_tile
XML=/home/ubuntu/src/openstreetmap-carto-be/mapnik-fr.xml
HOST=localhost
TILESIZE=256
MAXZOOM=18
CORS=*

[osmbe-nl]
URI=/osmbe-nl/
TILEDIR=/var/lib/mod_tile
XML=/home/ubuntu/src/openstreetmap-carto-be/mapnik-nl.xml
HOST=localhost
TILESIZE=256
MAXZOOM=18
CORS=*

Enable connection to database

Make sure the IP address of the database server is correct in project.mml !

You will need to use ~/.pgpass file to define the password to connect to PostgreSQL : https://www.postgresql.org/docs/current/libpq-pgpass.html.

Render

Clone openstreetmap-carto-be repository

cd ~/src
git clone git://github.com/jbelien/openstreetmap-carto-be.git

Clone render_list_geo.pl repository

cd ~/src
git clone git://github.com/alx77/render_list_geo.pl.git

Run the render process

First, give access to the database for the rendering server IP address (/etc/postgresql/9.6/main/pg_hba.conf).

To render osmbe :

sh ~/src/openstreetmap-carto-be/scripts/render/process.sh

To render osmbe-fr :

sh ~/src/openstreetmap-carto-be/scripts/render/process.sh fr

To render osmbe-nl :

sh ~/src/openstreetmap-carto-be/scripts/render/process.sh nl

If you want to know in details what will happen, check https://github.com/jbelien/openstreetmap-carto-be/blob/master/scripts/render/process.sh !

Follow the process

tail -f /var/log/syslog | grep " TILE "