Change the the renderd settings by editing the /usr/local/etc/renderd.conf (you’ll need to do it as root via “sudo”) and change the following five lines, uncommenting (removing the ‘;’) when required. They are found in the [renderd], [mapnik] and [default] sections.
socketname=/var/run/renderd/renderd.sock plugins_dir=/usr/local/lib/mapnik/input font_dir=/usr/share/fonts/truetype/ttf-dejavu XML=/usr/local/share/maps/style/OSMBright/OSMBright.xml HOST=localhost
Create the files required for the mod_tile system to run (remember to change username to your user’s name):
sudo mkdir /var/run/renderd sudo chown username /var/run/renderd sudo mkdir /var/lib/mod_tile sudo chown username /var/lib/mod_tile
Next, we need to tell the Apache web server about our new mod_tile installation.
Using your favourite text editor, create the file /etc/apache2/conf-available/mod_tile.conf and add one line:
LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so
Apache’s default website configuration file needs to be modified to include mod_tile settings. Modify the file /etc/apache2/sites-available/000-default.conf to include the following lines immediately after the admin e-mail address line:
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 30
Tell Apache that you have added the new module, and restart it:
sudo a2enconf mod_tile sudo service apache2 reload
Tuning your system
A tile server can put a lot of load on hard- and software. The default settings may therefore not be appropriate and a significant improvement can potentially be achieved through tuning various parameters.
The default configuration for PostgreSQL 9.3 needs to be tuned for the amount of data you are about to add to it. Edit the file /etc/postgresql/9.3/main/postgresql.conf and make the following changes:
shared_buffers = 128MB checkpoint_segments = 20 maintenance_work_mem = 256MB autovacuum = off
These changes require a kernel configuration change, which needs to be applied every time that the computer is rebooted. As root via “sudo”, edit /etc/sysctl.conf and add these lines near the top after the other “kernel” definitions:
# Increase kernel shared memory segments – needed for large databases
Reboot your computer. Run this:
sudo sysctl kernel.shmmax
and verify that it displays as 268435456.