How to install Nominatim

  • On debian 7 you can use packages:
  •  # apt-get install osmosis osm2pgsql libxml2-dev libbz2-dev
     # apt-get install php5 php-pear php5-pgsql php5-json php-db
     # apt-get install postgresql postgis postgresql-contrib postgresql-9.4-postgis-2.1 postgresql-9.4-postgis-2.1-scripts
  • You might want to tune your PostgreSQL installation so that the later steps make best use of your hardware. You should tune the following parameters in your postgresql.conf file. Debian location /etc/postgresql/9.4/main/postgresql.conf
    1. shared_buffers (4GB)
    2. maintenance_work_mem (10GB)
    3. work_mem (50MB)
    4. effective_cache_size (24GB)
    5. synchronous_commit = off
    6. checkpoint_segments = 100
    7. checkpoint_timeout = 10min
    8. checkpoint_completion_target = 0.9

    The numbers in brackets behind some parameters seem to work fine for 32GB RAM machine. Adjust to your setup.

    For the initial import, you should also set:

    1. fsync = off
    2. full_page_writes = off

    Don’t forget to switch them on again afterwards or you risk database corruption.

    Autovacuum must not be switched off because it ensures that the tables are frequently analysed.

  • Downloading Nominatim
  • all actions will be done under user nominatim.

     # su - nominatim
     $ cd; wget
     $ tar xjvf Nominatim-2.4.0.tar.bz2
  • Customization of the Installation
  • You can customize Nominatim by creating a local configuration file settings/local.php. Have a look at settings/settings.php for available configuration settings.

    Here is an example of a local.php:

       // Paths
       @define('CONST_Postgresql_Version', '9.4');
       @define('CONST_Postgis_Version', '2.1');
       // Website settings
       @define('CONST_Website_BaseURL', 'http://mysite/nominatim/');
  • Creating postgres accounts
  • The import needs to be done with a postgres superuser with the same name as the account doing the import. You can create such a postgres superuser account by running:

    $ sudo -u postgres createuser -s nominatim

    Where root is the name of the account that will be used to perform the installation. You should ensure that this user can log in to the database without requiring a password (e.g. using ident authentication). This is the default on most distributions. See trust authentication for more information.
    In brief edit


    put into the file a string

    host    all             all               trust


    host    all             all               md5

    and restart the postgres.

  • Create website user
  • Create the website user www-data as a PostgreSQL database role

    $ sudo createuser -SDR www-data
  • Nominatim module reading permissions
  •  $ chmod +x ~/Nominatim-2.4.0
     # chmod +x ~/Nominatim-2.4.0/module
  • Compilation shared object
    • Install additional packages:
    • $ sudo apt-get install gcc postgresql-server-dev-9.4
    • Run some commands
    • $ cd ~/Nominatim-2.4.0/module/ # going to directory where nominatim.c stores
      $ gcc nominatim.c -fPIC -I/usr/include/postgresql/9.4/server/ -I. -c # making object file with position independent code (PIC)
      $ gcc --shared -o nominatim.o # making shared object from an object file

  • Compilation nominatim ELF
    • $ cd Nominatim-2.4.0/nominatim/
    • gcc postgresql.c sprompt.c input.c import.c export.c index.c nominatim.c -o nominatim  -I/usr/include/postgresql/ -I/usr/include/libxml2 -I/usr/include/ -pthread -L/usr/lib/postgresql -lpq -lz  -lxml2 -lbz2
    • When compilation process is done you can remove additional packages with dev suffix (libbz2-dev etc).

  • Import and index OSM data
    • replace path to osm2psql in ~/Nominatim-2.4.0/settings/settings.php:
    •  @define('CONST_Osm2pgsql_Binary', '/usr/bin/osm2pgsql');

      or insert such string into ~/Nominatim-2.4.0/settings/local.php

    • download pbf file of necessary countries
    • $ wget

    • and start import
    • $ cd ~/Nominatim-2.4.0/utils/
      $ ./setup.php --osm-file ~/RU-MOW.osm.pbf --all --osm2pgsql-cache 10000 2>&1 | tee setup.log
  • Import and index OSM data
    • add a line with path to osm2psql in ~/Nominatim-2.4.0/settings/local.php:
    •  @define('CONST_Osm2pgsql_Binary', '/usr/bin/osm2pgsql');
    • download pbf file of necessary countries
    • $ wget

    • and start import
    • $ cd ~/Nominatim-2.4.0/utils/
      $ ./setup.php --osm-file ~/RU-MOW.osm.pbf --all --osm2pgsql-cache 10000 2>&1 | tee setup.log
  • Set up the website
  • Here is an example of virtual host for nominatim:

    <VirtualHost *:80>
            DocumentRoot /var/www/
            LogLevel error
            ErrorLog ${APACHE_LOG_DIR}/nominatim.navixy.ru_error.log
            CustomLog ${APACHE_LOG_DIR}/nominatim.navixy.ru_access.log combined
        <Directory "/var/www/">
            Options FollowSymLinks MultiViews
            AddType text/html   .php     

    /var/www/ should be replaced with the directory where you have set up the Nominatim website in the step above.remove

    After making changes in the apache config you need to restart apache.

    The following instructions will make Nominatim available at

    • Create the directory for the website and make sure it is writable by the install user and readable by Apache:
    • sudo mkdir -m 755 /var/www/
      sudo chown nominatim /var/www/

    • Set up the website
    • ./utils/setup.php --create-website /var/www/

      You will need to make sure settings/local.php is configured with correct values for CONST_Website_BaseURL. see above.

  • P.S. For merging multiple pbf files you need do something like this:
  • $ sudo apt-get install osmctools
    $ mkfifo p1 p2
    $ osmconvert a.pbf --out-o5m -o=p1 & osmconvert b.pbf --out-o5m -o=p2 & osmconvert p1 p2 -o=all.pbf

    And import result file all.pbf using setup.php as shown above.

If you have more questions please contact our support team

Contact Us

USA: +1 858 815 9045

Mexico: +52 334 1642158

UK: +44 808 1641499

France: +33 644 605141

Germany: +49 157359 88250

Russia: +7 495 317 1622

Log in