tile.libre.is
Tile server for https://maps.libre.is/.
Not running at the moment, until more disk space is available.
switch2osm.org
Self-hosting tiles for maps.
Debian
Install deps.
sudo apt install sudo screen locate libapache2-mod-tile renderd git tar \
unzip wget bzip2 apache2 lua5.1 mapnik-utils python3-mapnik \
python3-psycopg2 python3-yaml gdal-bin node-carto postgresql \
postgresql-contrib postgis postgresql-15-postgis-3 \
postgresql-15-postgis-3-scripts osm2pgsql net-tools curl
PostGIS
Thusly.
Tune Postgres, ala:
shared_buffers = 1GB
work_mem = 50MB
maintenance_work_mem = 10GB
autovacuum_work_mem = 2GB
wal_level = minimal
checkpoint_timeout = 60min
max_wal_size = 10GB
checkpoint_completion_target = 0.9
max_wal_senders = 0
random_page_cost = 1.0
sudo -u postgres -i
createuser _renderd
createdb -E UTF8 -O _renderd gis
psql
At the Postgres prompt:
\c gis
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
ALTER TABLE geometry_columns OWNER TO _renderd;
ALTER TABLE spatial_ref_sys OWNER TO _renderd;
\q
Carto
Set up Openstreet map Carto:
mkdir ~/src
cd ~/src
git clone https://github.com/gravitystorm/openstreetmap-carto
cd openstreetmap-carto
carto project.mml > mapnik.xml
Map Data
Just using Azerbaijan for example, until more disk is available…
mkdir ~/data
cd ~/data
wget https://download.geofabrik.de/asia/azerbaijan-latest.osm.pbf
# meh, should have separate user...
chmod o+rx ~
sudo -u _renderd osm2pgsql -d gis --create --slim -G --hstore \
--tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua \
-C 2500 --number-processes 1 \
-S ~/src/openstreetmap-carto/openstreetmap-carto.style \
~/data/azerbaijan-latest.osm.pbf
Or do the whole planet. If created above, maybe faster to drop the old database first than do an update. XXX
mkdir ~/data
cd ~/data
# Find a mirror here:
# https://wiki.openstreetmap.org/wiki/Planet.osm
# planet-latest.osm.pbf is 77G
wget https://ftp.osuosl.org/pub/openstreetmap/pbf/planet-latest.osm.pbf
chmod o+rx ~
sudo -u _renderd osm2pgsql -d gis --create --slim -G --hstore \
--tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua \
-C 98304 --number-processes 8 \
-S ~/src/openstreetmap-carto/openstreetmap-carto.style \
~/data/planet-latest.osm.pbf
Indexes
Thusly.
cd ~/src/openstreetmap-carto/
sudo -u _renderd psql -d gis -f indexes.sql
Shapefiles
Thusly.
cd ~/src/openstreetmap-carto/
mkdir data
sudo chown _renderd data
sudo -u _renderd scripts/get-external-data.py
Fonts
Thusly.
cd ~/src/openstreetmap-carto/
scripts/get-fonts.sh
renderd
Edit /etc/renderd.conf thusly, add to bottom, changing “accountname” to the user used above:
[s2o]
URI=/hot/
XML=/home/accountname/src/openstreetmap-carto/mapnik.xml
HOST=localhost
TILESIZE=256
MAXZOOM=20
Edit /usr/lib/systemd/system/renderd.service and add to [Service] section:
Environment=G_MESSAGES_DEBUG=all
Apache
Thusly…
cd /etc/apache2/conf-available/
sudo wget https://raw.githubusercontent.com/openstreetmap/mod_tile/python-implementation/etc/apache2/renderd.conf
sudo a2enconf renderd
sudo systemctl reload apache2
sudo systemctl daemon-reload
sudo systemctl restart renderd
sudo systemctl restart apache2
sudo mkdir /var/lib/mod_tile
sudo chown _renderd /var/lib/mod_tile
sudo /etc/init.d/renderd restart
sudo /etc/init.d/apache2 restart
Then go check it here:
View Tiles
Thus.
cd /var/www/html
sudo wget https://raw.githubusercontent.com/SomeoneElseOSM/mod_tile/switch2osm/extra/sample_leaflet.html
sudo mv sample_leaflet.html index.html
sudo sed -i -e 's/127.0.0.1/tile.libre.is/g' index.html
Using Tiles
See:
Certbot
Add certs.
sudo apt install python3-certbot-apache
sudo certbot -d tile.libre.is
sudo systemctl restart apache2
TODO
Get more space.
Add more tiles…