Nominatim is a tool that can be used for geocoding addresses and reverse geocoding coordinates. This tutorial will guide you through the installation process of Nominatim on NetBSD.
Before we proceed with the installation, make sure that the following prerequisites are met:
We need to install the required dependencies for Nominatim to work. Run the following command to install them:
sudo pkgin update
sudo pkgin install build-essential git libxml2 libxml2-dev libgeos libgeos-dev libpqxx libpqxx-dev proj proj-dev proj-bin proj-data curl php php7-pgsql php-fpm pgsql-server
Next, we need to download Nominatim from Git. Run the following commands to clone the repository:
cd /usr/local
sudo git clone --recursive https://github.com/openstreetmap/Nominatim.git
In this step, we need to configure and build the Nominatim project. Run the following commands:
cd Nominatim
sudo ./autogen.sh
sudo ./configure --with-postgresql-libraries=/usr/pkg/lib --with-postgresql-includes=/usr/pkg/include/pgsql/server/
sudo make
This process might take some time to complete. Once done, you can verify the build by running the following command:
sudo make install
Now, we need to configure PostgreSQL to work with Nominatim. Run the following commands:
sudo su - postgres
createdb nominatim
psql -c "CREATE USER nominatim WITH PASSWORD 'password';"
psql -c "ALTER USER nominatim WITH SUPERUSER;"
In this step, we need to setup Nominatim by creating a configuration file. Navigate to the nominatim directory and run the following command:
cd /usr/local/Nominatim
sudo cp ./local.php.dist ./local.php
Edit the local.php file with your appropriate configurations. Replace the your_email@domain.com
with your email address. Also, replace the values as shown below:
@define('CONST_Database_DSN', 'pgsql://nominatim:password@localhost/nominatim');
@define('CONST_Osm2pgsql_Binary', '/usr/local/bin/osm2pgsql');
@define('CONST_Pyosmium_Binary', '/usr/local/bin/pyosmium-get-changes');
@define('CONST_Mapnik2_Binary', '/usr/local/bin/mapnik-render');
@define('CONST_Map_Config_File', '/usr/local/share/maps/style/osm-carto/mapnik.xml');
@define ('CONST_Website_BaseURL', 'http://127.0.0.1/nominatim/');
@define('CONST_MultipleSearchServers', '0');
@define('CONST_Database_ReadOnly', '0');
@define('CONST_Show_Quadtree', 0);
Save and close the file.
Finally, we can now import the data. To do this, first download the OSM data for your desired region from Geofabrik and save the .osm.pbf
file in /usr/local/share/nominatim/data
.
Run the following command to import data:
sudo ./utils/setup.php --osm-file /usr/local/share/nominatim/data/<your_file>.osm.pbf --all --osm2pgsql-cache 20000
This process might take some time to complete. Once done, you can start the Nominatim service:
sudo cp /usr/local/Nominatim/utils/systemd/nominatim.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start nominatim
You have successfully installed and configured Nominatim on NetBSD. You can now use it to geocode addresses and reverse geocode coordinates.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!