How to install Open Source Routing Machine (OSRM) on Debian Latest

This tutorial will guide you through the process of installing Open Source Routing Machine (OSRM) on Debian Latest. OSRM is an open-source solution for route planning and navigation, which provides fast route calculations and optimizations for car, bike and foot transportation modes.

Prerequisites

Before starting the installation, make sure you have the following prerequisites:

Step 1: Download and Install OSRM

  1. Open your terminal and run the following command to download and install the dependencies:

    sudo apt-get update && sudo apt-get install build-essential cmake pkg-config libbz2-dev libxml2-dev libzip-dev libboost-all-dev liblua5.2-dev libtbb-dev
    
  2. Download the latest OSRM source code from the project repository by running the following command:

    git clone https://github.com/Project-OSRM/osrm-backend.git
    
  3. Navigate to the downloaded directory:

    cd osrm-backend
    
  4. Create a 'build' directory and navigate into it:

    mkdir build && cd build
    
  5. Run the following command to generate a makefile:

    cmake ..
    
  6. Build the application by running the following command:

    cmake --build .
    
  7. Install the application by running the following command:

    sudo cmake --build . --target install
    

Step 2: Download and Prepare the Map Data

  1. Download the map data for your region of interest from OpenStreetMap.org, for example, by using the "Export" function. Save the data file in the 'osrm-backend' directory.

  2. Extract the map data by running the following command:

    osrm-extract <your_map_data>.osm.pbf
    
  3. Prepare the map data for routing by running the following command:

    osrm-contract <your_map_data>.osrm
    

Step 3: Run OSRM Server

  1. Start the server by running the following command:

    osrm-routed <your_map_data>.osrm
    
  2. The server will start running, and you should see a similar output in your terminal:

    [info] listening on: http://127.0.0.1:5000
    
  3. Open your web browser and navigate to the following URL to access OSRM:

    http://127.0.0.1:5000/{service}?{parameters}
    

    Replace {service} with the desired routing service, e.g., route, nearest, table.

    Replace {parameters} with the required parameters for the service, e.g., loc={latitude},{longitude}.

    You can also use http://{server-ip}:{port}/{service}?{parameters} to access the server from another machine on the same network.

    Example: http://127.0.0.1:5000/route/v1/driving/-122.42,37.78;-122.45,37.79?steps=true

Congratulations! You have successfully installed and set up Open Source Routing Machine (OSRM) on Debian Latest.

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!