Set Up OSM Nominatim Geocoding Server on Ubuntu 20.04

In a previous tutorial, I explained the process of building your own OSM tile server on Ubuntu 20.04. This tutorial is going to show you how to set up Nominatim Geocoding server on Ubuntu 20.04. Nominatim provides search functionality for OpenStreetMap, so if a visitor enters an address in a search box, the latitude/longitude location for that address will be returned.

Note: If you are going to set up Nominatim for the entire planet, then you should spin up another server for Nominatim, because it will also require 64GB RAM and 1TB SSD.

Step 1: Install and Configure PostgreSQL

Note: If OSM tile server and Nominatim are installed on the same server, then you can skip this step, because you have already done this when setting up the OSM tile server.

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

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

Then install PostGIS, which is a geospatial extension to PostgreSQL.

sudo apt install postgis postgresql-14-postgis-3

Then we need to tune PostgreSQL for maximal performance. Edit the main configuration file.

sudo nano /etc/postgresql/14/main/postgresql.conf

Finf the the following parameters in this file and use the following values.

shared_buffers = 15GB
work_mem = 1GB
maintenance_work_mem = 10GB
effective_cache_size = 24GB
synchronous_commit = off
max_wal_size = 1GB
checkpoint_timeout = 10min
checkpoint_completion_target = 0.9
fsync = off
full_page_writes = off

Save and close the file. Restart PostgreSQL for the changes to take effect.

sudo systemctl restart postgresql

Note that you should turn on fsync and full_page_write after importing the OSM database, or you risk corrupting the database.

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/14/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. Edit /etc/sysctl.conf file.

sudo nano /etc/sysctl.conf

Add the following line to allocate 7950 huge pages.

vm.nr_hugepages = 7950

Save and close the file. Then apply the changes.

sudo sysctl -p

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

Step 2: Build Nominatim From Source

Install dependency packages to build Nominatim.

sudo apt update

sudo apt install build-essential cmake g++ libboost-dev libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev apache2 php php-pgsql libapache2-mod-php php-intl php-cgi phpunit php-codesniffer python3-setuptools python3-dev python3-pip python3-psycopg2 python3-tidylib python3-behave python-pytest pylint git clang-tidy postgresql-server-dev-14

Create the nominatim user. (No need to create a password for this user.)

sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim

Change to the /srv/nominatim/ directory.

cd /srv/nominatim/

Grant permissions to your own user account.

sudo apt install acl

sudo setfacl -R -m u:username:rwx /srv/nominatim/

Download Nominatim from the official website.

wget https://nominatim.org/release/Nominatim-3.5.1.tar.bz2

Extract the tarball.

tar xvf Nominatim-3.5.1.tar.bz2

Create the build directory.

mkdir build

Change to this directory and configure the build environment.

cd build

cmake /srv/nominatim/Nominatim-3.5.1

Compile the source code.

make

Build Nominatim From Source

Step 3: Configure Nominatim

The default configuration file for Nominatim is /srv/nominatim/build/settings/settings.php. We can create a local.php file and add our modifications there.

sudo nano /srv/nominatim/build/settings/local.php

Add the following lines in the file.

<?php
 @define('CONST_Website_BaseURL', '/nominatim/');
 @define('CONST_Default_Lat', 55.0);
 @define('CONST_Default_Lon', 1.0);
 @define('CONST_Default_Zoom', 6);
 @define('CONST_Map_Tile_URL', 'https://tile.linuxbabe.com/osm/{z}/{x}/{y}.png');

The above configuration defines

  • The path of the Nominatim instance relative to your tile server.
  • Default latitude, longitude, and zoom level.
  • URL of your OSM tile server. By default, Nominatim uses the public https://tile.openstreetmap.org tile server. Here I use my own tile server.

You can also take a look at the /srv/nominatim/build/settings/settings.php file and add your own customizations if the need arises. For example, if you are going to import a large dataset (Europe, North America, planet, etc.), it’s a good practice to enable flat node storage of node locations, so node coordinates will be stored in a simple file instead of the database, saving you import time and disk storage.

@define('CONST_Osm2pgsql_Flatnode_File', '/srv/nominatim/flatnode.file');

Save and close the file.

Step 4: Import OSM Database

Download Wikipedia importance dump file, which will improve the quality of the Nomiatim search results.

cd /srv/nominatim/Nominatim-3.5.1/data

wget https://www.nominatim.org/data/wikimedia-importance.sql.gz

Download US and UK postcodes data.

wget https://www.nominatim.org/data/us_postcode_data.sql.gz

wget https://www.nominatim.org/data/gb_postcode_data.sql.gz

Download country code data file.

wget -O country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz

Then you need to download an OSM file and import it to PostgreSQL. You can go to http://download.geofabrik.de to download the extract you need. You can also use the PBF file during the tile server setup process.

Create the www-data user in PostgreSQL, so the web server will have read-only access to the database.

sudo -u postgres createuser www-data

Grant permission to the postgres user.

sudo setfacl -R -m u:postgres:rwx /srv/nominatim/

Switch to the postgres user.

sudo -u postgres -i

And run the following command to import OSM extracts to PostgreSQL.

cd /srv/nominatim/build/

/srv/nominatim/build/utils/setup.php --osm-file /home/osm/great-britain-latest.osm.pbf --all 2>&1 | tee setup.log

It will automatically create the nominatim database in PostgreSQL and import OSM extracts with osm2pgsql.

Nominatim import speed for planet pbf on AMD EPYC 7282

After importing the database, the indexing process will begin. There are 30 ranks in total.

nominatim-indexing-process-20.04

Once it’s finished, run the following command to verify.

/srv/nominatim/build/utils/check_import_finished.php

nominatim import osm database

Exit out of the postgres user.

exit

Step 5: Set Up Apache

If Nominatim is installed on the OSM tile server, then edit the tile server configuration file.

sudo nano /etc/apache2/sites-enabled/tileserver_site-le-ssl.conf

Add the following lines between the VirtualHost tags.

<Directory "/srv/nominatim/build/website">
  Options FollowSymLinks MultiViews
  AddType application/json   .php
  DirectoryIndex search.php
  Require all granted
</Directory>

alias /nominatim /srv/nominatim/build/website

Save and close the file. Then reload Apache.

sudo systemctl reload apache2

If you are setting up Nominatim on a separate server, then you need to install Apache and PHP.

sudo apt install apache2 php7.4 libapache2-mod-php7.4 php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline

Create a virtual host for Nominatim.

sudo nano /etc/apache2/sites-enabled/nominatim.conf

Add the following lines in this file.

<VirtualHost *:80>
    ServerName nominatim.example.com

    DocumentRoot /srv/nominatim/build/website

    <Directory "/srv/nominatim/build/website">
          Options FollowSymLinks MultiViews
          AddType application/json   .php
          DirectoryIndex search.php
          Require all granted
   </Directory>

   alias /nominatim /srv/nominatim/build/website

    ErrorLog ${APACHE_LOG_DIR}/nominatim_error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/nominatim_access.log combined
</VirtualHost>

Save and close the file. Then restart Apache.

sudo systemctl restart apache2

Now visit https://tile.yourdomain.com/nominatim. You will see your Nomiatim instance.

nominatim setup with own tile server

The CSS file is located at /srv/nominatim/build/website/css/search.css, if you want to customize the looking.

Step 6: Update Nominatim Database

To keep the Nominatim database up to date, we need to install Pyosmium. It’s available from the default software repository, but it’s recommended to install the latest version using pip3.

sudo pip3 install osmium

This will install a binary /usr/local/bin/pyosmium-get-changes. Edit Nominatim configuration file.

sudo nano /srv/nominatim/build/settings/local.php

Add the following line to specify the location of pyosmium-get-changes.

@define('CONST_Pyosmium_Binary', '/usr/local/bin/pyosmium-get-changes');

Next, we need to tell Nominatim where to download updates. By default, it’s configured to download updates from https://planet.openstreetmap.org/replication/minute. If you downloaded the OSM PBF file from geofabrik.de, then it’s better to also download updates from there.

To find the update URL for your own map, go to https://download.geofabrik.de/ and locate your region. Then find the URL for the .osc.gz file.

nominatim update database

This URL is the update URL.

Nominatim Replication URL

Add the following line in /srv/nominatim/build/settings/local.php file. You need to use your own update URL.

// base URL of the replication service
@define('CONST_Replication_Url', 'http://download.geofabrik.de/europe/great-britain-updates');
// How often upstream publishes diffs
@define('CONST_Replication_Update_Interval', '86400');
// How long to sleep if no update found yet
@define('CONST_Replication_Recheck_Interval', '900');

Save and close the file. Grant permissions to the postgres user.

sudo setfacl -R -m "u:postgres:rwx" /srv/nominatim/build/

Then swith to the postgres user.

sudo -u postgres -i

Initialize the update process.

/srv/nominatim/build/utils/update.php --init-updates

Update Nominatim database.

/srv/nominatim/build/utils/update.php --import-osmosis-all

Step 7: Set Up Cron Job For Automatic Update

Edit root user’s Crontab file.

sudo crontab -e

Add the following line in this file.

@daily sudo -u postgres /srv/nominatim/build/utils/update.php --import-osmosis-all

Save and close the file. If you don’t want to automatically update Nominatim database, simply remove the above line from your Crontab file.

How to Add Search Functionality to a Slippy Map

I assume your slippy map is displayed using the Leaflet JavaScript library. To add search functionality to your map, you need to use a Leaflet geocoding plugin. I will show you how to use Leaflet Control Geocoder. It’s actually very simple.

Suppose you used the following HTML code to display your slippy map.

<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([54,1],6);
           L.tileLayer('https://tile.yourdomain.com/osm/{z}/{x}/{y}.png',{maxZoom:19}).addTo(map);  
         </script>
   </body>
</html>

Now you need to add the following two lines in the HTML header to use the Leaflet Control Geocoder plugin.

<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css" />
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>

Then add the following function to the <script>...</script> code so the search functionality will be added to your map.

L.Control.geocoder().addTo(map);

The final HTML code looks like this:

<html>
    <head>
        <meta charset="UTF-8">
        <title>My first osm</title>
        <link rel="stylesheet" type="text/css" href="leaflet.css"/>     
        <link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css" />
        <script type="text/javascript" src="leaflet.js"></script>
        <script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
        <style>
           #map{width:100%;height:100%}
        </style>
    </head>

    <body>
        <div id="map"></div>
        <script>
           var map = L.map('map').setView([54,1],6);
           L.tileLayer('https://tile.yourdomain.com/osm/{z}/{x}/{y}.png',{maxZoom:19}).addTo(map); 
           L.Control.geocoder().addTo(map);
         </script>
   </body>
</html>

Save and close the file. Then reload the map in your web browser, you should see a search button on the upper-right corner.

By default, Leaflet Control Geocoder uses the public https://nominatim.openstreetmap.org geocoding service. To make it use your own Nominatim geocoding service, delete the following line.

L.Control.geocoder().addTo(map);

Add the following lines instead. Replace the URL with the URL of your Nominatim geocoding service. Note that you should not leave out the trailing slash.

      var geocoder = L.Control.Geocoder.nominatim({serviceUrl:'https://tile.yourdomain.com/nominatim/'});
      if (URLSearchParams && location.search) {
        // parse /?geocoder=nominatim from URL
        var params = new URLSearchParams(location.search);
        var geocoderString = params.get('geocoder');
        if (geocoderString && L.Control.Geocoder[geocoderString]) {
          console.log('Using geocoder', geocoderString);
          geocoder = L.Control.Geocoder[geocoderString]();
        } else if (geocoderString) {
          console.warn('Unsupported geocoder', geocoderString);
        }
      }

      var control = L.Control.geocoder({
        query: 'Type Address here',
        placeholder: 'Search here...',
        geocoder: geocoder,
        position: 'topright'
      }).addTo(map);
      var marker;

      setTimeout(function() {
        control.setQuery('Type Address here');
      }, 12000);

The default position is topright. You can change it to topleft if you like to.

You can also add the following code for reverse geocoding. When a visitor clicks on a point on the map, the name of that address will appear.

      map.on('click', function(e) {
        geocoder.reverse(e.latlng, map.options.crs.scale(map.getZoom()), function(results) {
          var r = results[0];
          if (r) {
            if (marker) {
              marker
                .setLatLng(r.center)
                .setPopupContent(r.html || r.name)
                .openPopup();
            } else {
              marker = L.marker(r.center)
                .bindPopup(r.name)
                .addTo(map)
                .openPopup();
            }
          }
        });
      });

Save and close the file. Then reload the map in your web browser.

Improve Accuracy of Reverse Search

There are two types of search in Nominatim:

  • forward search, aka geocoding, returns latitude and longitude for an address
  • reverse search, aka reverse geocoding, returns an address for latitude and longitude, i.e when a visitor clicks on a point in the map.

If you do a reverse search, the marker pin and pop-up are not in the immediate proximity of the position on the map that you clicked, you need to increase the zoom level. The map.getZoom() function will get the current map view, which is set with the setView() function like so

var map = L.map('map').setView([54,1],6);

The zoom level is set to 6, which will give poor accuracy for reverse search. We can hard code the zoom level for reverse search like so:

geocoder.reverse(e.latlng, map.options.crs.scale(21), function(results)

i.e change map.getZoom() to 21. The maximum zoom level for reverse search is 21. You can choose another zoom level to suit your needs.

Troubleshooting

If the search functionality on your map doesn’t work, you can check the console of your web browser to find out what went wrong. Some folks may see the 406 not acceptable or a CORS not allowed error. Make sure you have set the correct MIME type for .php in the Apache configuration file. Some folks may have the following line, which can cause the above errors.

AddType text/html .php

It should be

AddType application/json .php

After changing the MIME type. Reload Apache for the changes to take effect.

sudo systemctl reload apache2

How to Upgrade PostgreSQL Database Server

The following instructions show how to upgrade from PostgreSQL 14 to PostgreSQL 15 after it’s released.

When a new version of PostgreSQL comes out, you can upgrade to take advantage of performance improvements. Simply run the following command, and the apt package manager will install the latest version of PostgreSQL from the apt.postgresql.org repository.

sudo apt update; sudo apt upgrade -y

After that, you also need to upgrade existing PostgreSQL clusters. Pro Tip: You should open a GNU Screen session to prevent connection drop because the upgrade will take some time.

screen

Change to the /srv/nominatim/build directory.

cd /srv/nominatim/build/

Remove all files and folders under this directory.

sudo rm * -r

Remove the postgresql-server-dev-14 package.

sudo apt remove postgresql-server-dev-14

Install the postgresql-server-dev-15 package.

sudo apt remove postgresql-server-dev-15

Rebuild Nomiatim from source.

cmake /srv/nominatim/Nominatim-3.5.1

make

Then list PostgreSQL clusters.

sudo pg_lsclusters

Sample output:

Ver Cluster Port Status Owner    Data directory              Log file
14  main    5432 online postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
15  main    5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log

As you can see, PostgreSQL 14 is using the default 5432 port. PostgreSQL 15 is using port 5433. Stop PostgreSQL server.

sudo systemctl stop postgresql

Let’s check the cluster status again with: sudo pg_lsclusters. They are all down.

Ver Cluster Port Status Owner    Data directory              Log file
14  main    5432 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
15  main    5433 down   postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log

Rename the cluster name of  PostgreSQL 14 from main to latest_stable.

sudo pg_renamecluster 15 main latest_stable

Then we need to shrink the PostgreSQL shared_buffer.

sudo nano /etc/postgresql/14/main/postgresql.conf

Decrease the value to prevent out-of-memory problem during upgrade. For example, I reduce the value from 15GB to 5GB.

shared_buffers = 5GB

Save and close the file.

Next, upgrade the old PostgreSQL 14 cluster. This works by copying the databases from /var/lib/postgresql/14/main/ directory to the /var/lib/postgresql/15/main/ directory with pg_dump and pg_restore.  Database configuration files will also be copied.

sudo pg_upgradecluster 14 main

nominatim upgrade postgresql

Start PostgreSQL  server.

sudo systemctl start postgresql

Now check if your application is working. If it’s working well, then drop the old cluster.

sudo pg_dropcluster 14 main

Check cluster status again:

sudo pg_lsclusters

If the upgrade is successful, you can change the shared_buffer back to the original value in the /etc/postgresql/15/main/postgresql.conf file. Don’t forget to restart PostgreSQL.

Wrapping Up

I hope this tutorial helped you set up Nominatim geocoding server on Ubuntu 20.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 6 Average: 5]

15 Responses to “Set Up OSM Nominatim Geocoding Server on Ubuntu 20.04

  • At this part of Step 1 :
    cmake /srv/nominatim/Nominatim-3.5.1

    I get the following result:
    — The C compiler identification is GNU 9.3.0
    — The CXX compiler identification is GNU 9.3.0
    — Check for working C compiler: /bin/cc
    — Check for working C compiler: /bin/cc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info – done
    — Detecting C compile features
    — Detecting C compile features – done
    — Check for working CXX compiler: /bin/c++
    — Check for working CXX compiler: /bin/c++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info – done
    — Detecting CXX compile features
    — Detecting CXX compile features – done
    — Building osm2pgsql 1.2.0
    — Building in C++11 mode
    — Looking for include file termios.h
    — Looking for include file termios.h – found
    — Looking for include file unistd.h
    — Looking for include file unistd.h – found
    — Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version “1.2.11”)
    — Looking for pthread.h
    — Looking for pthread.h – found
    — Performing Test CMAKE_HAVE_LIBC_PTHREAD
    — Performing Test CMAKE_HAVE_LIBC_PTHREAD – Failed
    — Looking for pthread_create in pthreads
    — Looking for pthread_create in pthreads – not found
    — Looking for pthread_create in pthread
    — Looking for pthread_create in pthread – found
    — Found Threads: TRUE
    — Found Protozero: /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/protozero/include (found suitable version “1.6.8”, minimum required is “1.6.3”)
    — Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version “2.2.9”)
    — Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version “1.0.8”)
    — Looking for BZ2_bzCompressInit
    — Looking for BZ2_bzCompressInit – found
    — Found Osmium: /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/libosmium (found suitable version “2.15.6”, minimum required is “2.14”)
    — Found Boost: /lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version “1.71.0”, minimum required is “1.50”) found components: system filesystem
    — Found PostgreSQL: /usr/lib/x86_64-linux-gnu/libpq.so (found version “13.0”)
    — Libraries used to build: Boost::system;Boost::filesystem;/usr/lib/x86_64-linux-gnu/libpq.so;/usr/lib/x86_64-linux-gnu/libz.so;-lpthread;/usr/lib/x86_64-linux-gnu/libexpat.so;/usr/lib/x86_64-linux-gnu/libbz2.so;/usr/lib/x86_64-linux-gnu/libproj.so
    — Looking for clang-tidy
    — Looking for clang-tidy – found /bin/clang-tidy
    — Tests disabled. Set BUILD_TESTS=ON to enable tests.
    — Found PythonInterp: /bin/python3 (found suitable version “3.8.5”, minimum required is “3”)
    CMake Warning at CMakeLists.txt:69 (message):
    pyosmium-get-changes not found (required for updates)

    — Using PHP binary /bin/php
    CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the CMake files:
    Boost_INCLUDE_DIR
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src
    used as include directory in directory /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src

    — Configuring incomplete, errors occurred!
    See also “/srv/nominatim/build/CMakeFiles/CMakeOutput.log”.
    See also “/srv/nominatim/build/CMakeFiles/CMakeError.log”.

    Researching this leads me down several different paths, so far none have panned out. Have you encountered this, or do you know how I might work through it?

    Links to the output file and the error log are here:
    https://drive.google.com/file/d/1yFXmBtahhq5PpggtXFSa4-PvwBgZZB8F/view?usp=sharing

    https://drive.google.com/file/d/1-5jYstq9_XmhUGXDRqS4hWcZyHTZpHSH/view?usp=sharing

  • An inspiring article, most of these steps worked for us. Had to install PostGres and PostGis as the dev postgres-sql didn’t play for me.

  • The Nominatim 3.6.0 doesn’t have any html output. Please update your tutorial with Nominatim 3.6.0 and describe how to get an html outpuy that use local map tiles. Thanks.

    • Xiao Guoan (Admin)
      3 years ago

      Yes. The default HTML page doesn’t work with Nominatim 3.6.0, but you can still use Leaflet Control Geocoder to add search functionality to a slippy map.

      • When I want to use Leaflet Control Geocoder, with Nominatim 3.6.0, what should I write instead of this line in index.html:
        var geocoder = L.Control.Geocoder.nominatim({serviceUrl:’https://tile.yourdomain.com/nominatim/’});
        I think in Nominatim 3.6.0 I don’t have /nominatim/ URI. So what can I do? And is there any further changes that I should do? Please help me.

        • Michael Keuper
          3 years ago

          I edited the Control.OSMGeocoder.js at line 177 and 178.
          177 -> replaced https with http because I am not using http configuration yet inside my own network
          178 -> var url = protocol + “//192.168.2.112/nominatim” + L.Util.getParamString(params), ……
          simply replaced it with my server-IP

          sure it can be done much better, but this works fine for me 😉

      • L.Control.geocoder().addTo(map); works excellent for me. But when I want to use my server for search (instead of internet), no result shows. I added var geocoder = L.Control.Geocoder.nominatim({serviceUrl:’https://tile.yourdomain.com/nominatim/’}); and next lines but no search result. I did previous steps exactly right.

  • Michael Keuper
    3 years ago

    thank you for this tutorial, you made my day!
    after 2 days of trial and error I managed, this guide handy, to set up the geosearch within 2.5 hrs. (using a 170MB osm File). Absolutely great work.

    Stay save and sane.

  • Good day! thanks for the manual. Could you help, this is what happened after the command MAKE.

    Scanning dependencies of target osm2pgsql_lib
    [ 2%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/db-copy.cpp.o
    [ 5%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/expire-tiles.cpp.o
    [ 8%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/gazetteer-style.cpp.o
    [ 11%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/geometry-processor.cpp.o
    [ 14%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/id-tracker.cpp.o
    [ 17%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/middle-pgsql.cpp.o
    [ 20%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/middle-ram.cpp.o
    [ 23%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/node-persistent-cache.cpp.o
    [ 26%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/node-ram-cache.cpp.o
    [ 29%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/options.cpp.o
    [ 32%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/osmdata.cpp.o
    [ 35%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/osmium-builder.cpp.o
    [ 38%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/output-gazetteer.cpp.o
    [ 41%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/output-multi.cpp.o
    [ 44%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/output-null.cpp.o
    [ 47%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/output-pgsql.cpp.o
    [ 50%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/output.cpp.o
    [ 52%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/parse-osmium.cpp.o
    [ 55%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/pgsql.cpp.o
    [ 58%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/processor-line.cpp.o
    [ 61%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/processor-point.cpp.o
    [ 64%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/processor-polygon.cpp.o
    [ 67%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/reprojection.cpp.o
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp: In member function ‘virtual osmium::geom::Coordinates {anonymous}::generic_reprojection_t::reproject(osmium::Location) const’:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:89:74: warning: ‘osmium::geom::Coordinates osmium::geom::transform(const osmium::geom::CRS&, const osmium::geom::CRS&, osmium::geom::Coordinates)’ is deprecated [-Wdeprecated-declarations]
    89 | deg_to_rad(loc.lat_without_check())));
    | ^
    In file included from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.hpp:10,
    from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:14:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/libosmium/osmium/geom/projection.hpp:126:46: note: declared here
    126 | inline OSMIUM_DEPRECATED Coordinates transform(const CRS& src, const CRS& dest, Coordinates c) {
    | ^~~~~~~~~
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:89:74: warning: ‘osmium::geom::Coordinates osmium::geom::transform(const osmium::geom::CRS&, const osmium::geom::CRS&, osmium::geom::Coordinates)’ is deprecated [-Wdeprecated-declarations]
    89 | deg_to_rad(loc.lat_without_check())));
    | ^
    In file included from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.hpp:10,
    from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:14:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/libosmium/osmium/geom/projection.hpp:126:46: note: declared here
    126 | inline OSMIUM_DEPRECATED Coordinates transform(const CRS& src, const CRS& dest, Coordinates c) {
    | ^~~~~~~~~
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp: In member function ‘virtual void {anonymous}::generic_reprojection_t::target_to_tile(double*, double*) const’:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:95:65: warning: ‘osmium::geom::Coordinates osmium::geom::transform(const osmium::geom::CRS&, const osmium::geom::CRS&, osmium::geom::Coordinates)’ is deprecated [-Wdeprecated-declarations]
    95 | osmium::geom::Coordinates(*lon, *lat));
    | ^
    In file included from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.hpp:10,
    from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:14:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/libosmium/osmium/geom/projection.hpp:126:46: note: declared here
    126 | inline OSMIUM_DEPRECATED Coordinates transform(const CRS& src, const CRS& dest, Coordinates c) {
    | ^~~~~~~~~
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:95:65: warning: ‘osmium::geom::Coordinates osmium::geom::transform(const osmium::geom::CRS&, const osmium::geom::CRS&, osmium::geom::Coordinates)’ is deprecated [-Wdeprecated-declarations]
    95 | osmium::geom::Coordinates(*lon, *lat));
    | ^
    In file included from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.hpp:10,
    from /srv/nominatim/Nominatim-3.5.1/osm2pgsql/src/reprojection.cpp:14:
    /srv/nominatim/Nominatim-3.5.1/osm2pgsql/contrib/libosmium/osmium/geom/projection.hpp:126:46: note: declared here
    126 | inline OSMIUM_DEPRECATED Coordinates transform(const CRS& src, const CRS& dest, Coordinates c) {
    | ^~~~~~~~~
    [ 70%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/sprompt.cpp.o
    [ 73%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/table.cpp.o
    [ 76%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/taginfo.cpp.o
    [ 79%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/tagtransform-c.cpp.o
    [ 82%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/tagtransform.cpp.o
    [ 85%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/util.cpp.o
    [ 88%] Building CXX object osm2pgsql/src/CMakeFiles/osm2pgsql_lib.dir/wildcmp.cpp.o
    [ 91%] Linking CXX static library libosm2pgsql.a
    [ 91%] Built target osm2pgsql_lib
    Scanning dependencies of target osm2pgsql
    [ 94%] Building CXX object osm2pgsql/CMakeFiles/osm2pgsql.dir/src/osm2pgsql.cpp.o
    [ 97%] Linking CXX executable osm2pgsql
    [ 97%] Built target osm2pgsql
    Scanning dependencies of target nominatim_lib
    [100%] Running external makefile /usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk
    /srv/nominatim/Nominatim-3.5.1/module/Makefile:11: warning: overriding recipe for target ‘install’
    /usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk:241: warning: ignoring old recipe for target ‘install’
    [100%] Built target nominatim_lib

  • Daniel Ubeda
    3 years ago

    Hi, I have installed everything in my Ubuntu 20.4, and it’s working fine!! Thanks for this tutorials.!!

    But I need more speed. I am trying to convert .meta files to .png files … but it is slow and would like to know if there is a way to generate .png files directly without generating the .meta files, and how to configure apache to show them? Could you help me? Thanks in advance

  • Another fine tutorial. On another note I noticed tiles expired after 3 days. I only found one method to prevent this, and that is to move the creation date in to the future. Do you know of another way? The other resolutions were quite byzantine, but would probably be better in the long run. Default is the folder used in your implementation.

    find /var/lib/mod_tile/default/ -type f -exec touch -t 202301120000 {} \;

    Thanks again, this tutorial is needed and appreciated!

  • tooneamelt
    3 years ago

    Not sure if it’s just me that ran into this, but after running nominatim install, renderd stopped working. I had to run

    postgres@gisserver:~$ psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO osm;" -d gis
    

    In order for the tiles to process again. Otherwise, I got errors when renderd tried to contact postgres in the renderd logs :$ journalctl -eu renderd

  • Any chance this can get updated to better jive with the newer version of nominatim?

  • MorpheousHex
    3 years ago

    now that the whole process have changed with Nominatim 4.0 can you update the tutorial for that version that is the latest

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here