Setting Up Nominatim for Bangladesh

This guide will walk you through the installation and setup of Nominatim on a Debian-based system.

Step 1: Install Required Packages

Update your package list and install the necessary packages:

apt-get update

apt-get install build-essential cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev \
libbz2-dev libpq-dev \
postgresql-server-dev-13 postgresql-13-postgis-3 \
postgresql-contrib-13 postgresql-13-postgis-3-scripts \
php-cli php-pgsql php-intl libicu-dev python3-dotenv \
python3-psycopg2 python3-psutil python3-jinja2 \
python3-icu python3-datrie

Step 2: Install and Configure Sudo

Install sudo and add the necessary paths:

apt-get install sudo

export PATH=$PATH:/usr/sbin/:/sbin

Create the nominatim user:

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

Set environment variables for the nominatim user:

export USERNAME=nominatim
export USERHOME=/srv/nominatim

Set permissions for the user home directory:

chmod a+x $USERHOME

Create PostgreSQL users:

sudo -u postgres createuser -s $USERNAME
sudo -u postgres createuser www-data

Step 3: Install Nominatim

Switch to the nominatim user and download Nominatim:

cd $USERHOME
su - nominatim
wget https://nominatim.org/release/Nominatim-4.1.0.tar.bz2
tar xf Nominatim-4.1.0.tar.bz2

Create build directory and compile Nominatim:

export USERNAME=nominatim
export USERHOME=/srv/nominatim
mkdir $USERHOME/build
cd $USERHOME/build
cmake $USERHOME/Nominatim-4.1.0
make
exit  # or sudo su
cd $USERHOME/build
make install

Create project directories:

mkdir $USERHOME/nominatim-project
mkdir $USERHOME/nominatim-project/website

Download OSM data:

export PATH=$PATH:/usr/sbin/:/sbin
cd /srv/nominatim/nominatim-project
wget https://download.geofabrik.de/asia/bangladesh-latest.osm.pbf

Import OSM data into Nominatim:

su - nominatim
cd /srv/nominatim/nominatim-project/
nominatim import --osm-file bangladesh-latest.osm.pbf 2>&1 | tee setup.log

Step 4: Set Up Apache2

Install Apache2 and PHP module:

su

apt-get install apache2 libapache2-mod-php

Configure Apache2 for Nominatim:

export USERNAME=nominatim
export USERHOME=/srv/nominatim

tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
<Directory "/srv/nominatim/nominatim-project/website">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted

### If we process the deny rules before the allow rules, we can effectively create a whitelist of allowed IP addresses.
#Order deny,allow
#deny from all
#allow from 127.0.0.1
</Directory>

Alias /nominatim /srv/nominatim/nominatim-project/website
EOFAPACHECONF

Enable the Nominatim configuration and restart Apache2:

export PATH=$PATH:/usr/sbin/:/sbin
a2enconf nominatim
systemctl restart apache2

Summary

By following these steps, you have successfully installed and configured Nominatim on your system. Nominatim should now be running and accessible via your Apache web server.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top