Build Your Own OpenStreetMap Tile Server on Ubuntu 22.04
OpenStreetMap (OSM) is a user-contributed, freely-editable world map. It’s an open-source and self-hosted alternative to Google Maps. This tutorial will show you how to build your own OpenStreetMap tile server on Ubuntu 22.04 so you don’t have to use a proprietary map service.
OpenStreetMap Features
- OpenStreetMap data covers the whole world, making it easy to support users in any country or every country.
- OpenStreetMap is updated every minute of every hour of every day, and these updates are available to you in real-time.
- OpenStreetMap data is free and open – there is no subscription fee and no page-view fee.
- OpenStreetMap data is rich and detailed, containing huge amounts of data that is relevant to people on the ground – the people who collected it.
Hint: This tutorial shows how to set up a raster tile server. If you want a vector tile server, you should instead follow this TileServer GL/OpenMapTiles tutorial. Don’t know which one is better? Just choose vector tile server, which is much faster than raster tile server.
Prerequisites/Hardware Requirements
It’s recommended to use a server with a clean fresh OS.
The required RAM and disk space depend on which country’s map you are going to use. For example,
- The UK map requires at least 12G RAM and 100GB disk space.
- The whole planet map requires at least 32G RAM and 1TB SSD (Solid State Drive). It’s not viable to use a spinning hard disk for the whole planet map.
You will need more disk space if you are going to pre-render tiles to speed up map loading in the web browser, which is highly recommended. Check this tile disk usage page to see how much disk space are required for pre-rendering tiles. For example, if you are going to pre-render tiles from zoom level 0 to zoom level 15 for the planet map, an extra 460 GB disk space is required.
Another thing to note is that importing large map data, like the whole planet, to PostgreSQL database takes a long time. Consider adding more RAM and especially using SSD instead of spinning hard disk to speed up the import process.
If you are going to host the entire world map, I recommend you buy the extra-large VPS from Contabo, which boasts
- A 10 core CPU
- 60 GB RAM
- 1.6 TB Intel Optane SSD
It costs just 26.99 €/month.
Step 1: Upgrade Software
It’s always a good practice to update server software before doing any major work on your server. Log into your server via SSH and run the following command.
sudo apt update; sudo apt upgrade -y
Step 2: Install PostgreSQL Database Server and the PostGIS Extension
We will use PostgreSQL to store map data. The PostgreSQL team always strives to make performance improvements with every new version. Run the following 4 commands to install the latest version of PostgreSQL.
echo "deb [signed-by=/etc/apt/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list sudo mkdir -p /etc/apt/keyrings/ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/keyrings/postgresql.asc sudo apt update sudo apt install -y postgresql postgresql-contrib postgresql-15 postgresql-client-15
Then install PostGIS, which is a geospatial extension to PostgreSQL.
sudo apt install postgis postgresql-15-postgis-3
PostgreSQL database server will automatically start and listens on 127.0.0.1:5432
. The postgres
user will be created on the OS during the installation process. It’s the super user for PostgreSQL database server. By default, this user has no password and there’s no need to set one because you can use sudo
to switch to the postgres
user and log into PostgreSQL server.
sudo -u postgres -i
Now you can create a PostgreSQL database user osm
.
createuser osm
Then create a database named gis
and at the same time make osm
as the owner of the database. Please don’t change the database name. Other tools like Renderd and Mapnik assume there’s a database named gis
.
createdb -E UTF8 -O osm gis
Next, create the postgis
and hstore
extension for the gis
database.
psql -c "CREATE EXTENSION postgis;" -d gis psql -c "CREATE EXTENSION hstore;" -d gis
Set osm
as the table owner.
psql -c "ALTER TABLE spatial_ref_sys OWNER TO osm;" -d gis
Exit from the postgres
user.
exit
Create osm
user on your operating system so the tile server can run as osm
user. The following command will create a system user without password.
sudo adduser --system --group osm
Step 3: Download Map Stylesheet and Map Data
Change to osm’s home directory.
cd /home/osm/
Grant permissions to your user account with the following command. Replace username
with your real username.
sudo apt install acl
sudo setfacl -R -m u:username:rwx /home/osm/
Download the latest CartoCSS map stylesheets to the osm
user’s home directory with git.
sudo apt install git git clone https://github.com/gravitystorm/openstreetmap-carto.git
Then run one of the following commands to download the map data in PBF (ProtoBufBinary) format.
Britain and Ireland (1.7G)
wget -c http://download.geofabrik.de/europe/britain-and-ireland-latest.osm.pbf
Europe (25.8G)
wget -c http://download.geofabrik.de/europe-latest.osm.pbf
North America (11.8G)
wget -c http://download.geofabrik.de/north-america-latest.osm.pbf
South America (2.9G)
wget -c http://download.geofabrik.de/south-america-latest.osm.pbf
Central America (570MB)
wget -c http://download.geofabrik.de/central-america-latest.osm.pbf
Asia (11.2G)
wget -c http://download.geofabrik.de/asia-latest.osm.pbf
Africa (5.5G)
wget -c http://download.geofabrik.de/africa-latest.osm.pbf
Whole planet (66G). Note: I recommend only downloading the whole plant map when you really need to display the map of the whole world, or you will waste time waiting for the tile server to process unnecessary data.
wget -c http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
or
wget -c https://download.bbbike.org/osm/planet/planet-latest.osm.pbf
If you want other map of individual country/state/province/city, go to http://download.geofabrik.de. Also, BBBike.org provides extracts of more than 200 cities and regions worldwide in different formats.
Step 4: Optimize PostgreSQL Server Performance
The import process can take some time. To speed up this process, we can tune some PostgreSQL server settings to improve performance. Edit PostgreSQL main configuration file.
sudo nano /etc/postgresql/15/main/postgresql.conf
First, we should change the value of shared_buffer
. The default setting is:
shared_buffers = 128MB
This is too small. The rule of thumb is to set it to 25% of your total RAM (excluding swap space). For example, my VPS has 60G RAM, so I set it to:
shared_buffers = 15GB
Find the following line.
#work_mem = 4MB #maintenance_work_mem = 64MB
Again, the value is too small. I use the following settings.
work_mem = 1GB maintenance_work_mem = 8GB
Then find the following line.
#effective_cache_size = 4GB
If you have lots of RAM like I do, you can set a higher value for the effective_cache_size like 20G.
effective_cache_size = 20GB
Save and close the file. Restart PostgreSQL for the changes to take effect.
sudo systemctl restart postgresql
By default, PostgreSQL would try to use huge pages in RAM. However, Linux by default does not allocate huge pages. Check the process ID of PostgreSQL.
sudo head -1 /var/lib/postgresql/15/main/postmaster.pid
Sample output:
7031
Then check the VmPeak value of this process ID.
grep ^VmPeak /proc/7031/status
Sample output:
VmPeak: 16282784 kB
This is the peak memory size that will be used by PostgreSQL. Now check the size of huge page in Linux.
cat /proc/meminfo | grep -i huge
Sample output:
AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB
We can calculate how many huge pages we need. Divide the VmPeak value by the size of huge page: 16282784 kB / 2048 kB = 7950
. Then we need to edit the sysctl files to change Linux kernel parameters. Instead of editing the /etc/sysctl.conf
file, we create a custom config file, so your custom configurations won’t be overwritten when upgrading software packages.
sudo touch /etc/sysctl.d/60-custom.conf
Then run the following command to allocate 7950 huge pages.
echo "vm.nr_hugepages = 7950" | sudo tee -a /etc/sysctl.d/60-custom.conf
Save and close the file. Apply the changes.
sudo sysctl -p /etc/sysctl.d/60-custom.conf
If you check the meminfo again,
cat /proc/meminfo | grep -i huge
We can see there are 7950 huge pages available.
AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 7950 HugePages_Free: 7950 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB
Restart PostgreSQL to use huge pages.
sudo systemctl restart postgresql
Hint: Don’t disable huge pages once PostgreSQL starts using them, or PostgreSQL will complain that it could not map anonymous shared memory and cannot allocate memory.
Use Screen on Remote Servers
Since the import process can take a long time and your computer might be disconnected from Internet, it’s recommended to use the screen utility to keep your session alive. Install screen on the Ubuntu 22.04 server:
sudo apt install screen
Then start screen:
screen
Upon first launch, you will see an introduction text, simply press Enter
to end. Then you will be able to run commands as usual.
Step 5: Import the Map Data to PostgreSQL
To import map data, we need to install osm2pgsql
which converts OpenStreetMap data to postGIS-enabled PostgreSQL databases.
sudo apt install osm2pgsql
Grant permissions to the postgres user.
sudo setfacl -R -m u:postgres:rwx /home/osm/
Switch to the postgres
user.
sudo -u postgres -i
Run the following command to load map stylesheet and map data into the gis
database. Replace great-britain-latest.osm.pbf
with your own map data file.
osm2pgsql --slim -d gis --hstore --multi-geometry --number-processes 10 --tag-transform-script /home/osm/openstreetmap-carto/openstreetmap-carto.lua --style /home/osm/openstreetmap-carto/openstreetmap-carto.style -C 32000 /home/osm/britain-and-ireland-latest.osm.pbf
where
--slim
: run in slim mode rather than normal mode. This option is needed if you want to update the map data using OSM change files (OSC) in the future.-d gis
: select database.--hstore
: add tags without column to an additional hstore (key/value) column to PostgreSQL tables--multi-geometry
: generate multi-geometry features in postgresql tables.--style
: specify the location of style file--number-processes
: number of CPU cores on your server. I have 10.-C
flag specifies the cache size in MegaBytes. It should be around 70% of the free RAM on your machine. Bigger cache size results in faster import speed. For example, my server has 60GB free RAM, so I can specify-C 32000
. Be aware that PostgreSQL will need RAM for shared_buffers. Use this formula to calculate how big the cache size should be:(Total RAM - PostgreSQL shared_buffers) * 70%
- Finally, you need to specify the location of map data file.
Command Output:
If you are going to import the full planet map data, then use the --drop
option and the --flat-nodes
option to increase the import speed. Note that the --flat-nodes
option isn’t suitable for small maps.
osm2pgsql --slim -d gis --drop --flat-nodes /home/osm/nodes.cache --hstore --multi-geometry --number-processes 10 --tag-transform-script /home/osm/openstreetmap-carto/openstreetmap-carto.lua --style /home/osm/openstreetmap-carto/openstreetmap-carto.style -C 32000 /home/osm/planet-latest.osm.pbf
RAM usage will gradually increase during the importing process.
Now you probably don’t need to do other things on your server. Since you are using Screen, you can press Ctrl+A, release those keys, and then press D key to detach from the current Screen session. You will see a message like below.
[detached from 32113.pts-1.focal]
This tells me that the previous Screen session ID is 32113. You can log out from the SSH session and even shut down your computer. Don’t worry, the OSM import process is still running. When you need to come back and check the import progress, SSH into your server and run the following command to get the previous Screen Session ID.
screen -ls
Sample output:
There is a screen on: 32113.pts-1.focal (05/19/2020 03:45:29 PM) (Detached) 1 Socket in /run/screen/S-linuxbabe.
Then you can re-attach to the previous Screen session.
screen -r 32113
And you will be able to continue your work. Once the import is complete, grant all privileges of the gis
database to the osm
user.
psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO osm;" -d gis
Exit from the postgres
user.
exit
Note: If the osm2pgsql import isn’t finished yet, please don’t continue with step 6.
Troubleshooting
If you encounter the following error when importing map data from PBF file,
PBF error : invalid Blobheader size (> max_blob_header_size)
it’s probably because your PBF file is corrupt. Verify the md5sum of the PBF file like below.
md5sum great-britain-latest.osm.pbf
Compare the result with the md5sum value on the PBF file download page.
Step 6: Install Renderd and mod_tile
renderd
is a daemon for rendering OpenStreetMap tiles from the PostgreSQL database.mod_tile
is an Apache module that is used to serve tiles to clients (e.g. web browsers)
The default Ubuntu repository does not include mod_tile
and renderd
, but we can install them from the OSM PPA.
sudo apt install software-properties-common sudo add-apt-repository ppa:osmadmins/ppa sudo apt install apache2 libapache2-mod-tile renderd
The Apache web server will be installed and a config file for renderd
will also be created at /etc/apache2/conf-available/renderd.conf
.
Enable the tile
module.
sudo a2enmod tile
Next, create a virtual host for the tile server.
sudo nano /etc/apache2/sites-available/tileserver_site.conf
Add the following lines in this file. Replace tile.your-domain.com
with your real domain name. Don’t forget to DNS A record.
<VirtualHost *:80>
ServerName tile.your-domain.com
LogLevel info
Include /etc/apache2/conf-available/renderd.conf
</VirtualHost>
Save and close the file. Enable this virtual host.
sudo a2ensite tileserver_site.conf
Restart Apache for the changes to take effect.
sudo systemctl restart apache2
The render daemon will automatically start, as can be seen with:
systemctl status renderd
Sample output:
● renderd.service - Daemon that renders map tiles using mapnik Loaded: loaded (/lib/systemd/system/renderd.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-08-21 14:35:51 CEST; 1min 50s ago Docs: man:renderd Main PID: 74593 (renderd) Tasks: 15 (limit: 72256) Memory: 46.4M CPU: 2.143s CGroup: /system.slice/renderd.service └─74593 /usr/bin/renderd -f
Step 7: Generate Mapnik Stylesheet
Install the required packages.
sudo apt install -y curl unzip gdal-bin mapnik-utils libmapnik-dev python3-pip
We also need to install nodejs
and npm
from the upstream repository with the following commands.
sudo apt-get install -y nodejs npm
Then install the carto
package with npm
.
sudo npm install -g carto
Install the psycopg2
Python module.
sudo -H pip3 install psycopg2==2.8.5
Switch to the postgres
user.
sudo -u postgres -i
Cd into the carto style directory.
cd /home/osm/openstreetmap-carto/
Get shapefiles.
scripts/get-external-data.py
Sample output:
INFO:root:Starting load of external data into database INFO:root:Checking table simplified_water_polygons INFO:root: Download complete (23715086 bytes) INFO:root: Decompressing file INFO:root: Importing into database INFO:root: Import complete INFO:root:Checking table water_polygons INFO:root: Download complete (810110834 bytes) INFO:root: Decompressing file INFO:root: Importing into database INFO:root: Import complete INFO:root:Checking table icesheet_polygons INFO:root: Download complete (52620984 bytes) INFO:root: Decompressing file INFO:root: Importing into database INFO:root: Import complete INFO:root:Checking table icesheet_outlines INFO:root: Download complete (53286106 bytes) INFO:root: Decompressing file INFO:root: Importing into database INFO:root: Import complete INFO:root:Checking table ne_110m_admin_0_boundary_lines_land INFO:root: Download complete (57325 bytes) INFO:root: Decompressing file INFO:root: Importing into database INFO:root: Import complete
If you encounter the following error message while running the above command, then you have DNS issues. Simply wait for several minutes and run the Python script again.
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
Now build the Mapnik XML stylesheet with the carto
map stylesheet compiler.
carto project.mml > style.xml
If there are the following warning messages, you can ignore them.
Warning: style/admin.mss:64:6 Styles do not match layer selector #admin-low-zoom. Warning: style/admin.mss:59:6 Styles do not match layer selector #admin-low-zoom. Warning: style/admin.mss:55:6 Styles do not match layer selector #admin-low-zoom. Warning: style/admin.mss:51:6 Styles do not match layer selector #admin-low-zoom. Warning: style/admin.mss:27:19 Styles do not match layer selector #admin-low-zoom. Warning: style/admin.mss:26:19 Styles do not match layer selector #admin-low-zoom.
Grant all privileges of the gis
database to the osm
user.
psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO osm;" -d gis
Exit from the postgres
user.
exit
Step 8: Install Fonts
Install TrueType fonts.
sudo apt install ttf-dejavu
To display non-Latin characters, install the following packages.
sudo apt install fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-hinted fonts-noto-unhinted
Step 9: Configure renderd
Edit renderd
config file.
sudo nano /etc/renderd.conf
In the [renderd]
section, change the number of threads according to the number of CPU cores on your server.
num_threads=10
Add a default
layer. Lines beginning with semicolons (;) are comments.
; ADD YOUR LAYERS:
[default]
URI=/osm/
XML=/home/osm/openstreetmap-carto/style.xml
HOST=tile.your-domain.com
By default, renderd allows a max zoom level of 18. If you need zoom level 19, add the following line in the [default]
section.
MAXZOOM=19
Save and close the file. Then create a new directory for the renderd service.
sudo mkdir /etc/systemd/system/renderd.service.d/
Create a custom config file under this directory.
sudo nano /etc/systemd/system/renderd.service.d/custom.conf
Add the following lines in this file.
[Service] User=osm
Save and close the file. Change the ownership of /run/renderd/
and /var/cache/renderd/tiles/
directory.
sudo chown osm /run/renderd/ -R sudo chown osm /var/cache/renderd/tiles/ -R
Then restart renderd service.
sudo systemctl daemon-reload sudo systemctl restart renderd
You need to check the log of renderd.
sudo journalctl -eu renderd
Make sure renderd does not produce any error in the log after the restart, or the map won’t be displayed.
Step 10: Test
In your web browser address bar, type
tile.your-domain.com/osm/0/0/0.png
You should see the tile of the world map. Congrats! You just successfully built your own OSM tile server.
If you have enabled the UFW firewall, be sure to open port 80 and 443 with the following command.
sudo ufw allow 80,443/tcp
If you see the 404 not found error, simply wait a few minutes, refresh the page in your browser and it should be able to load the tile of world map. If it still won’t load, then restart renderd service (sudo systemctl restart renderd
). You might also need to pre-render tiles (step 12) in order to display the world map tile.
Step 11: Display Your Tiled Web Map
Now you have a working OSM tile server, you need to use a JavaScript map library to display the map on your other servers. In this tutorial, I’m creating the web map on the tile server, but you can do it on any other server.
A tiled web map is also known as a slippy map in OpenStreetMap terminology. There are two free and open-source JavaScript map libraries you can use for your tile server: OpenLayer and Leaflet. The advantage of Leaflet is that it is simple to use and your map will be mobile-friendly.
OpenLayer
To display your slippy map with OpenLayer, download JavaScript and CSS from openlayer.org and extract it to the webroot folder.
cd /var/www/html/ sudo wget https://github.com/openlayers/openlayers/releases/download/v5.3.0/v5.3.0.zip sudo unzip v5.3.0.zip
Next, create the index.html
file.
sudo nano /var/www/html/index.html
Paste the following HTML code in the file. Replace red-colored text and adjust the longitude, latitude and zoom level according to your needs.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Accessible Map</title> <link rel="stylesheet" href="http://tile.your-domain.com/v5.3.0/css/ol.css" type="text/css"> <script src="http://tile.your-domain.com/v5.3.0/build/ol.js"></script> <style> a.skiplink { position: absolute; clip: rect(1px, 1px, 1px, 1px); padding: 0; border: 0; height: 1px; width: 1px; overflow: hidden; } a.skiplink:focus { clip: auto; height: auto; width: auto; background-color: #fff; padding: 0.3em; } #map:focus { outline: #4A74A8 solid 0.15em; } </style> </head> <body> <a class="skiplink" href="#map">Go to map</a> <div id="map" class="map" tabindex="0"></div> <button id="zoom-out">Zoom out</button> <button id="zoom-in">Zoom in</button> <script> var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ url: 'http://tile.your-domain.com/osm/{z}/{x}/{y}.png' }) }) ], target: 'map', controls: ol.control.defaults({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ collapsible: false }) }), view: new ol.View({ center: [244780.24508882355, 7386452.183179816], zoom:5 }) }); document.getElementById('zoom-out').onclick = function() { var view = map.getView(); var zoom = view.getZoom(); view.setZoom(zoom - 1); }; document.getElementById('zoom-in').onclick = function() { var view = map.getView(); var zoom = view.getZoom(); view.setZoom(zoom + 1); }; </script> </body> </html>
Save and close the file. Now you can view your slippy map by typing your sub-domain in the browser address bar.
tile.your-domain.com
or
tile.your-domain.com/index.html
Leaflet
To display your slippy map with Leftlet, download JavaScript and CSS from leftletjs.com and extract it to the webroot folder.
cd /var/www/html/ sudo wget http://cdn.leafletjs.com/leaflet/v1.7.1/leaflet.zip sudo unzip leaflet.zip
Next, create the index.html
file. If there is already an index.html
file, then delete the original content.
sudo nano /var/www/html/index.html
Paste the following HTML code in the file. Replace red-colored text and adjust the longitude, latitude and zoom level according to your needs.
<html> <head> <meta charset="UTF-8"> <title>My first osm</title> <link rel="stylesheet" type="text/css" href="leaflet.css"/> <script type="text/javascript" src="leaflet.js"></script> <style> #map{width:100%;height:100%} </style> </head> <body> <div id="map"></div> <script> var map = L.map('map').setView([55,0.8],6); L.tileLayer('http://tile.your-domain.com/osm/{z}/{x}/{y}.png',{maxZoom:18}).addTo(map); </script> </body> </html>
Save and close the file. Now you can view your slippy map by typing your server IP address in browser.
tile.your-domain.com
or
tile.your-domain.com/index.html
Step 12: Pre-render Tiles
Rendering tiles on-the-fly will increase the map loading time in web browser. To pre-render tiles instead of rendering on the fly, use the following render_list
command. Use -z
and -Z
flag specify the zoom level and replace the number of threads according to the number of CPU cores on your server. Render_list
renders a list of map tiles by sending requests to the rendering daemon. Pre-rendered tiles will be cached in /var/lib/mod_tile
directory.
render_list -m default -a -z 0 -Z 19 --num-threads=10
If later you updated the map data, you can pre-render all tiles again by using the --force
option.
render_list -m default -a -z 0 -Z 19 --num-threads=10 --force
To render map tiles in the background, add the &
symbol at the end.
render_list -m default -a -z 0 -Z 19 --num-threads=10 &
Now you can close the terminal window. To check the rendering progress, open another SSH session, and run the following command.
sudo journalctl -eu renderd
The above command will show the latest log of the renderd
service. The following lines show that my OSM server is now rendering map tiles at zoom level 12.
renderd[20838]: DEBUG: START TILE default 12 1008-1015 4056-4063, new metatile renderd[20838]: Rendering projected coordinates 12 1008 4056 -> -10175297.205328|-19724422.274944 -10097025.688364|-19646150.757980 to a 8 x 8 tile renderd[20838]: DEBUG: DONE TILE default 12 1008-1015 3984-3991 in 0.799 seconds renderd[20838]: DEBUG: Sending render cmd(3 default 12/1008/3984) with protocol version 2 to fd 18 renderd[20838]: DEBUG: Got incoming request with protocol version 2 renderd[20838]: DEBUG: Got command RenderBulk fd(18) xml(default), z(12), x(1008), y(4064), mime(image/png), options() renderd[20838]: DEBUG: START TILE default 12 1008-1015 4064-4071, new metatile renderd[20838]: Rendering projected coordinates 12 1008 4064 -> -10175297.205328|-19802693.791908 -10097025.688364|-19724422.274944 to a 8 x 8 tile
Step 13: Enable HTTPS
To encrypt HTTP traffic, we can obtain and install a free TLS certificate from Let’s Encrypt. The osmadmins/ppa
PPA contains a malfunctioning certbot
binary, so I recommend installing certbot
from the Snap store.
sudo apt install snapd sudo snap install --classic certbot
Then run the following command to obtain and install TLS certificate.
sudo /snap/bin/certbot --apache --agree-tos --redirect --hsts --staple-ocsp --must-staple --email [email protected] -d tile.your-domain.com
Once the certificate is installed, refresh the web page and you will see a lock in the address bar.
If you see a yellow triangle in Firefox address bar, that means the tile URLs are still using HTTP. You need to edit the index.html file and replace all HTTP protocol with HTTPS with the following command.
sudo sed -i 's/http/https/g' /var/www/index.html
Step 14: Enable HTTP2
To further improve map loading performance, you can enable HTTP2 protocol. First, you need to enable the HTTP2 module.
sudo a2enmod http2
Then open the SSL virtual host file.
sudo nano /etc/apache2/sites-enabled/tileserver_site-le-ssl.conf
Put the following directive after the opening <VirtualHost *:443>
tag.
Protocols h2 http/1.1
Save and close the file. Then restart Apache for the changes to take effect.
sudo systemctl restart apache2
Restrict Access to Your OSM Tile Server with HTTP Referrer Header
By default, anyone can use OpenLayer or Leaflet to create a slippy map with the URL of your tile server. To restrict access to your tile server, edit the Apache virtual host file.
sudo nano /etc/apache2/sites-enabled/tileserver_site-le-ssl.conf
Add the following lines in the <VirtualHost>
tags.
<Location /osm>
SetEnvIf Referer example\.com trusted_referer
Order deny,allow
Deny from all
Allow from env=trusted_referer
</Location>
The above code checks if the HTTP referer header includes your own domain. If not, access to the /osm
directory will be denied. The backslash is used to escape the dot character. To add multiple hostnames as trusted referrers, use the following syntax.
SetEnvIf Referer (example\.com|www\.example\.com|map\.example\.com) trusted_referer
Save and close the file. Then test the syntax.
sudo apache2ctl -t
If the syntax is Ok, reload Apache for the changes to take effect.
sudo systemctl reload apache2
Auto-Renew TLS Certificate
You can create Cron job to automatically renew TLS certificate. Simply open root user’s crontab file.
sudo crontab -e
Add the following line at the bottom of the file.
@daily /snap/bin/certbot renew --quiet && systemctl reload apache2
PostgreSQL Database and Web Server on Different Hosts
If your PostgreSQL and Apache web server reside on different hosts, then you need to edit the project.mml
file on the Apache host.
nano /home/osm/openstreetmap-carto-4.20.0/project.mml
Find the following lines:
osm2pgsql: &osm2pgsql type: "postgis" dbname: "gis" key_field: "" geometry_field: "way" extent: "-20037508,-20037508,20037508,20037508"
Specify the IP address of PostgreSQL database server.
osm2pgsql: &osm2pgsql
type: "postgis"
host: "10.0.0.2"
dbname: "gis"
key_field: ""
geometry_field: "way"
extent: "-20037508,-20037508,20037508,20037508"
Save and close the file. Then build the Mapnik XML stylesheet with the carto
map stylesheet compiler.
carto project.mml > style.xml
On the PostgreSQL database server, edit the main configuration file.
sudo nano /etc/postgresql/15/main/postgresql.conf
Add the following line to set PostgreSQL to listen on all interfaces.
listen_addresses = '*'
Save and close the file. Then edit the PostgreSQL client authentication configuration file.
sudo nano /etc/postgresql/15/main/pg_hba.conf
Add the following line at the end of the file to allow the osm
user to login from the Apache host. Replace 10.0.0.1 with the IP address of Apache host.
host gis osm 10.0.0.1/32 trust
Save and close the file. Then restart PostgreSQL.
sudo systemctl restart postgresql
Restart the render daemon on the Apache host.
sudo systemctl restart renderd
You need to check the log of renderd. Make sure renderd does not produce any error in the log, or the map won’t be displayed.
sudo journalctl -eu renderd
You should also restrict access to port 5432 of the PostgreSQL database server. For example, you can use the following UFW command to allow the IP address of Apache host only.
sudo ufw allow in from 10.0.0.1 to any port 5432
How to Update the gis Database
Stop renderd.
sudo systemctl stop renderd
Switch to the postgres
user.
sudo -u postgres -i
Delete the gis database.
dropdb gis;
Create a new database.
createdb -E UTF8 -O osm gis
Next, create the postgis
and hstore
extension for the gis
database.
psql -c "CREATE EXTENSION postgis;" -d gis psql -c "CREATE EXTENSION hstore;" -d gis
Set osm
as the table owner.
psql -c "ALTER TABLE spatial_ref_sys OWNER TO osm;" -d gis
Download the latest map.
wget http://download.geofabrik.de/europe/britain-and-ireland-latest.osm.pbf
Download the latest CartoCSS map stylesheets to the osm
user’s home directory with git.
git clone https://github.com/gravitystorm/openstreetmap-carto.git
Import the map data.
osm2pgsql --slim -d gis --hstore --multi-geometry --number-processes 10 --tag-transform-script /var/lib/postgresql/openstreetmap-carto/openstreetmap-carto.lua --style /var/lib/postgresql/openstreetmap-carto/openstreetmap-carto.style -C 32000 /var/lib/postgresql/great-britain-latest.osm.pbf
Once the import is complete, grant all privileges of the gis
database to the osm
user.
psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO osm;" -d gis
Cd into the carto style directory.
cd /var/lib/postgresql/openstreetmap-carto/
Get shapefiles.
scripts/get-external-data.py
Now build the Mapnik XML stylesheet with the carto
map stylesheet compiler.
carto project.mml > style.xml
Grant all privileges of the gis
database to the osm
user.
psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO osm;" -d gis
Exit from the postgres
user.
exit
Edit the /etc/renderd.conf
file and change
XML=/home/osm/openstreetmap-carto/style.xml
to
XML=/var/lib/postgresql/openstreetmap-carto/style.xml
Restart renderd.
sudo systemctl restart renderd
You can render all tiles again by using the --force
option.
render_list -m default -a -z 0 -Z 19 --num-threads=10 --force
Open another SSH session and check the renderd
journal log.
sudo journalctl -eu renderd
If a tile has been updated, then renderd
will re-render this tile.
DEBUG: START TILE default 7 0-7 16-23, age 655.16 days Rendering projected coordinates 7 0 16 -> -20037508.342800|12523442.714250 -17532819.799950|15028131.257100 to a 8 x 8 tile
Next Step
I hope this tutorial helped you set up OpenStreetMap tile server on Ubuntu 22.04. You may also want to set up Nominatim geocoding server to provide address lookup functionality.
As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂
Hi, first of all, thanks for the tutorial, it`s great.
Thanks for your tutorial!
Hi, Great tutorial! I was able to load in a small .pbf and serve the tiles to my leaflet viewer. I want to add another .pbf to my server and so I tried just doing the osm2pgsql line of Step-4 again, but with the new .pbf file. However when I restart the server (i.e. reboot the virtualmachine that is running it) I don’t see my knew area on the map, just the original one. Is there something else I need to do to load in new tiles?
Thanks!
*EDIT*
Actually I can see it now. I just had to zoom in and wait for a bit so the renderd service could process the request for the new area I was looking at.
Thank you Mr: Gouan, this is the most comprehensive and up-to-date tutorial I have seen.
Hi Mr. Guoan,
I’m having trouble with this.
I followed your instructions carefully but still got an error: 404 Not found when accessing it on browser.
Please help me. Thanks.
If it’s a 404 error, then you should first check out the Apache error log /var/log/apache2/error.log to find out what caused the error.
Thanks for your response.
It says
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
Checked the /var/run/renderd/ folder and found out that it was empty.
Tried to remove the semicolon on renderd.sock part of the renderd.conf, but still got the same error.
Really appreciate your help.
I’m sorry but I still got the same error.
I had the same problem. After investigating I found out that after the installation of mod_tile, its shared libraries were not yet registered correctly to the system. Run “sudo service renderd status” to check what is going wrong and also take a look into /var/log/syslog. In my case libiniparser.so.3 was not found by renderd. Simply running “sudo ldconfig” fixed it. After restarting renderd via “sudo service renderd restart” the error disappeared and everything was working as expected.
OMG that worked, thanks mate been stuck on the for a few hours 🙂
message to self for when i find my self here again as i just did, it is a L jason not an I in ldconfig 🙂
Hello,
Great page. Helped lot. I have one question. I installed by your steps and it works good. what If i wanna use different map style. How can i change map style without import all data again? thank you.
Loving the tutorial. Unfortunately I wasn’t able to get this working. 🙁 Any tile request create following debug note in the apache errorlog. debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
I get a 404 when I request the test tile. The requested URL /osm_tiles/0/0/0.png was not found on this server.
Sorry… I had something misspelled. Got it working straight away after redoing the tutorial.
Thanks so much!
Hello Mr Guoan,
Thank a lot for this tutorial …it was very helpful….
Great and simple tutorial that works !
Can i render png-tile-files in home dir for furher work ?
Command _render_list_ do render meta files, not png.
Yes, renderd generates meta files, but the mod_tile module in Apache will serve png tiles.
Hi Mr. Guoan,
I followed this tutorial throughly and came to end as all goes well.
But as u said your-server-ip/osm_tiles/0/0/0.png
when i am looking for map in web browser like localhost/osm_tiles/0/0/0.png, i m getting nothing.
could not find the directory there. need help
Same problem. I realized that I had a typo when I was writing the configuration files. I recommend you to check the status of renderd.
Hi, this is a great tutorial! It saves my life.
Hii Mr. Guoan, what a great tutorial! Thx
Thanks for your hard work!
Great tutorial, worked from 1st run!
how would one update the tile server using the osm.pbf files?
All the tutorials seems to stray away from the way that it was built in this tutorial.
You can find the update instruction at the end of this tutorial: https://www.linuxbabe.com/linux-server/osm-openstreetmap-tile-server-ubuntu-22-04#update-gis-database
Thank you for your tutorial!
Thanks. Great!
Really appreciate sir ,
At the step
I have following problem
Would you mind helping me please?
Thanks in advance
@sepehr
https://stackoverflow.com/questions/51288524/typeerror-cannot-read-property-hasownproperty-of-undefined-node-carto/51540310#51540310
With this great tutorial it was possible to run an own OSM server.
Thanks.
Reminder, given the recent compromises, you should include adding a firewall/iptables entry so that postgres is NOT open to the internet.
Thanks for your suggestion about firewall. By default, PostgreSQL listens on the localhost only.
Hi man,
great tutorial thanks a lot.
i have a question did you make any tutorial on how i can make a vector tile server?
thank you in advance.
Here’s a tutorial for setting up vector tile server: Fast Scalable Basemap with TileServer GL and OpenMapTiles (Ubuntu 22.04)
Hello Mr Guoan , first of all appreciating your work . its fantastic , helpful . But one question , that is : if i add a country extract as map data , then if it possible to add the whole planet later by overwriting the country extract map data in the postgreSQL database .
Yes, you can. See the how-to-update-gis-database instructions here: https://www.linuxbabe.com/linux-server/osm-openstreetmap-tile-server-ubuntu-22-04#update-gis-database
Hello,
followed your tutorial and was able to install my tile server nickel, thank you very much.
I wonder if I can install gisgraphy along with the tile server, because I need geocoding and reverse gecocoding services.
Any advice on how to proceed since tile server is already in production.
Thank you again
I have written a Nominatim geocoding tutorial: Set Up OSM Nominatim Geocoding Server on Ubuntu 22.04
What does it mean `ERROR: std::bad_alloc` ?
Probably out of RAM. You should decrease the cache size.
Step 10: Test
I get `The requested URL was not found on this server. Apache/2.4.54 (Ubuntu) Server at tile.grasp.deals Port 80 ` but the `journalctl -eu renderd` does not output any error… .
What do you suggest me to do ?
Hi is your problem resolved
Running on suggested Server von Contabu.
Planet import with flat-nodes slows down extremly at ways 🙁
0.28k/s
Do you have a clue why this happen?
Hi. I have a bit problem.
When a type:
I get this message:
What should I check?
Thank
Hi! Great tutorial… Seriously, the best one I have found. One question, how can I serve my map data as WMTS tiles to ArcGIS? I’m not sure how to create a WMTS_Capabilities file or where it should go. Do you have an example or tutorial for that?
I think that the –drop option in the database load command will prevent the possibility to update the database later according to the documentation as the ‘–slim’ tables needed for the update are no longer there.
Also I think that the load command show be executed from the _reader in stead of postgres the you would not need to open up access to allowing for anyone.
I have encountered a problem at the step test http://site/osm/0/0/0.png
Got 404
It turned out that apache process did not have enough rights to the renderd.socket file
Added rights with facl and it took off!
Hi there, thanks for the great tut. Helped us starting own tile server. We also get the warning about fonts not being found. I would find it helpful to have a chapter about periodically updating the tiles automatically. Is there any solution yet?
Best, c–
Hi! I’m getting the following error when trying to render a tile with zoom, I presume, 9 or 10, not sure, but keep getting this error, I’ll attach the image for it.
Any can help here?
Hi I get below in step 10 ,
renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
root@ubuntu-s-4vcpu-8gb-blr1-01:/home/osm# sudo journalctl -eu renderd
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans Syriac >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Bold’ >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Sans CJK JP >
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘Noto Emoji Regula>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinA Regular’>
Aug 17 06:08:50 ubuntu-s-4vcpu-8gb-blr1-01 renderd[18583]: Mapnik LOG> 2023-08-17 06:08:50: warning: unable to find face-name ‘HanaMinB Regular’>
Solucionei esse problema executando o script que instala as fontes do carto. `scripts/get-fonts.sh`
Além disso, tem uma das requisições que tu vai ter que usar o parâmetro `-k` para ele não conferir o certificado do site.
Thank you for the infomation.
I had the same problem with the fonts.
I did as follows:
1) I ran the script: /home/osm/openstreetmap-carto/scripts/get.fonts.sh -k
Necessarily with the -k parameter.
2) Copying the directory: /home/osm/openstreetmap-carto/scripts/fonts to the directory: /usr/shaer/fonts/truetype
Hi I followed the tutorial but at step 10 when I am opening the site , it says this site can’t be reached . Can you please help
I want delete all fonts . is it possible?
Hi,
I ran into an issue where the socket was not created with the right owner.
As a result the tiles could not be rendered, i think everyone will have the same issue.
I fixed this by adding the following line in /etc/systemd/system/renderd.service.d/custom.conf
RuntimeDirectory=renderd
Making the tutorial:
sudo nano /etc/systemd/system/renderd.service.d/custom.conf
[Service]
User=osm
RuntimeDirectory=renderd
This is my small contribution to anotherwise good tutorial.
Hi,
thank you for this greas tut. One year after my first installation, i want to extend the map. How can i do that? Actually i implemented berlinmap.pbf, but i need to have more around Berlin.
Is there a way i can do that via osm2pgsqlß
Thanks alot in advance
Is it recommended to create gis table indexes?
Switch2OSM instructions say they are essentially required since v5.3.0
https://switch2osm.org/serving-tiles/manually-building-a-tile-server-ubuntu-22-04-lts/
https://github.com/gravitystorm/openstreetmap-carto/blob/master/CHANGELOG.md#v530—2021-01-28
help me
error in scripts/get-external-data.py
You forgot to run this command?
It’s in step 5.
user@mapserver:/home/osm$ sudo journalctl -eu renderd
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.606: Rendering daemon started
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: Initialising request_queue
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: Parsing section renderd
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: Parsing render section 0
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: Parsing section mapnik
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd: unix socketname=/run/renderd/renderd.sock
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd: num_threads=4
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd: num_slaves=0
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd: tile_dir=/var/cache/renderd/tiles
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd: stats_file=/run/renderd/renderd.stats
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config mapnik: plugins_dir=/usr/lib/mapnik/3.1/input
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config mapnik: font_dir=/usr/share/fonts/truetype
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config mapnik: font_dir_recurse=1
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd(0): Active
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd(0): unix socketname=/run/renderd/renderd.sock
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd(0): num_threads=4
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd(0): tile_dir=/var/cache/renderd/tiles
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: config renderd(0): stats_file=/run/renderd/renderd.stats
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.607: Initialising unix server socket on /run/renderd/renderd.sock
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.608: Renderd is using mapnik version 3.1.0
Jan 22 04:53:55 mapserver renderd[33986]: ** INFO: 04:53:55.743: Running in foreground mode…
Jan 22 05:05:35 mapserver renderd[33986]: Failed to open stats file: 13
Jan 22 05:05:35 mapserver renderd[33986]: Failed to open stats file: 13
Jan 22 05:05:35 mapserver renderd[33986]: ** (process:33986): ERROR **: 05:05:35.774: Failed repeatedly to write stats, giving up
Jan 22 05:05:35 mapserver renderd[33986]: Failed to open stats file: 13
Jan 22 05:05:35 mapserver renderd[33986]: Failed to open stats file: 13
Jan 22 05:05:55 mapserver systemd[1]: Stopping Daemon that renders map tiles using mapnik…
Jan 22 05:05:55 mapserver systemd[1]: renderd.service: Deactivated successfully.
Jan 22 05:05:55 mapserver systemd[1]: Stopped Daemon that renders map tiles using mapnik.
Jan 22 05:05:55 mapserver systemd[1]: Started Daemon that renders map tiles using mapnik.
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.927: Rendering daemon started
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.927: Initialising request_queue
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Parsing section renderd
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Parsing render section 0
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Parsing section mapnik
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Parsing section default
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd: unix socketname=/run/renderd/renderd.sock
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd: num_threads=2
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd: num_slaves=0
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd: tile_dir=/var/cache/renderd/tiles
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd: stats_file=/run/renderd/renderd.stats
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config mapnik: plugins_dir=/usr/lib/mapnik/3.1/input
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config mapnik: font_dir=/usr/share/fonts/truetype
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config mapnik: font_dir_recurse=1
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd(0): Active
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd(0): unix socketname=/run/renderd/renderd.sock
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd(0): num_threads=2
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd(0): tile_dir=/var/cache/renderd/tiles
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config renderd(0): stats_file=/run/renderd/renderd.stats
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: config map 0: name(default) file(/home/osm/openstreetmap-carto-5.7.0/style.xml) uri(/osm/) htcp() host(192.168.30.100)
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Initialising unix server socket on /run/renderd/renderd.sock
Jan 22 05:05:55 mapserver renderd[34553]: ** INFO: 05:05:55.928: Renderd is using mapnik version 3.1.0
Jan 22 05:05:56 mapserver renderd[34553]: ** INFO: 05:05:56.104: Running in foreground mode…
Jan 22 05:05:56 mapserver renderd[34553]: ** INFO: 05:05:56.105: Loading parameterization function for
Jan 22 05:05:56 mapserver renderd[34553]: ** INFO: 05:05:56.105: Loading parameterization function for
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans Syriac Black’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Bold’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Bold’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-0’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-1’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans Syriac Black’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Bold’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Bold’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Sans CJK JP Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘Noto Emoji Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinA Regular’ in FontSet ‘fontset-2’
Jan 22 05:05:56 mapserver renderd[34553]: Mapnik LOG> 2024-01-22 05:05:56: warning: unable to find face-name ‘HanaMinB Regular’ in FontSet ‘fontset-2’
The entrance to Pay69 slot a direct web slot, is one of the ultimate online slot websites that allows slot enthusiasts to enter and start PG SLOT playing online slots for real money. It is known for its high reliability and credibility
my error in step9:
http://hostname/osm/0/0/0.png, response 404 Not Found nginx/1.18.0 (Ubuntu)
sudo journalctl -eu renderd, response:
Hello shokola
Did you solve the problem?
Really love the tutorial, worked flawlessly on 22.04, but I am encountering significant issues translating it to work on 24.04, was wondering if you had any plans to update/release a new tutorial for 24.04? Thanks!