This comprehensive guide walks you through the steps to serve your OpenTopoMap tiles via Apache and the renderd daemon. It assumes that your server is already set up for OpenTopoMap tile rendering.
Contents
Compile and install mod_tile
mkdir ~/src
cd ~/src
git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git
cd mod_tile
./autogen.sh && ./configure
mapnik-config --libs
mapnik-config --cflags
make CXXFLAGS="$(mapnik-config --cflags)" LDFLAGS="$(mapnik-config --libs)"
sudo make install
sudo make install-mod_tile
sudo ldconfig
If you run into multiple definition of `render_request_queue’ take the following steps.
In includes/daemon.h find the line:
struct request_queue * render_request_queue;
Change it to:
extern struct request_queue * render_request_queue;
Add one real definition to src/daemon.c:
#include "daemon.h"
struct request_queue * render_request_queue = NULL;
Inr includes/render_submit_queue.h find the line:
int work_complete;
Change it to:
extern int work_complete;
In src/render_submit_queue add:
int work_complete = 0;
In src/render_expired.c and src/render_list.c find the line:
int work_complete;
Change it to:
extern int work_complete
Rebuild:
make clean
make CXXFLAGS="$(mapnik-config --cflags)" LDFLAGS="$(mapnik-config --libs)
Create the renderd configuration
Edit /usr/local/etc/renderd.conf (substitute the user):
[renderd]
num_threads=4
tile_dir=/var/lib/mod_tile
stats_file=/var/run/renderd/renderd.stats
[mapnik]
plugins_dir=/usr/lib/mapnik/3.1/input
font_dir=/usr/share/fonts/truetype
font_dir_recurse=1
[opentopomap]
URI=/hot/
TILEDIR=/var/lib/mod_tile
XML=/home/<user>/OpenTopoMap/mapnik/opentopomap.xml
HOST=localhost
TILESIZE=256
MAXZOOM=20
sudo mkdir /var/lib/mod_tile
sudo chown <user> /var/lib/mod_tile
sudo mkdir /var/run/renderd
sudo chown <user> /var/run/renderd
Test the configuration:
renderd -f -c /usr/local/etc/renderd.conf
Configure Apache to load mod_tile and talk to renderd
Create /etc/apache2/conf-available/mod_tile.conf with one line:
LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so
Enable it:
sudo a2enconf mod_tile
Edit /etc/apache2/sites-available/000-default.conf. Between the ‘ServerAdmin’ and ‘DocumentRoot’ lines add:
LoadTileConfigFile /usr/local/etc/renderd.conf
ModTileRenderdSocketName /var/run/renderd/renderd.sock
ModTileRequestTimeout 0
ModTileMissingRequestTimeout 30
Reload twice:
sudo service apache2 reload
sudo service apache2 reload
Start renderd
sudo mkdir -p /var/run/renderd
sudo chown <user> /var/run/renderd
renderd -f -c /usr/local/etc/renderd.conf
Test in your browser (example for Kleve, Germany): http://<ip-address>/hot/14/8471/5427.png
Set up a service
In ~/src/mod_tile/debian/renderd.init set RUNASUSER to your username (username of the renderer):
RUNASUSER=<user>
sudo cp ~/src/mod_tile/debian/renderd.init /etc/init.d/renderd
sudo chmod u+x /etc/init.d/renderd
sudo cp ~/src/mod_tile/debian/renderd.service /lib/systemd/system/
sudo /etc/init.d/renderd start
sudo systemctl enable renderd