trafficpixels Blog
Questions? Suggestions? message me
How to install a BRouter web instance on a pc or server
What is BRouter?
BRouter is a routing software, meaning it can calculate a route on a map and generate navigation instructions. It can run on a smartphone or on a personal computer or a server. This guide explains how to install BRouter on a Debian-based system but it should work similar on oter Linux systems. After installation BRouter can be used by accessing it with a browser, similar to the original BRouter Web demo. This is only the brouter-web part of the software. It cannot create the .rd5 map files that brouter-web uses for navigation, you need to install the non-web part of BRouter, this process is explained in another Blogpost.
Prerequesites
Base system
You need a Linux system installed and know how to access its terminal to enter code. When a graphical environment is installed, there is often a start menu with an entry similar to "Terminal Emulator". If there is no graphical environment, then you are likely already looking at a terminal.
It is useful to have root access (have administrator privileges) in case you have to install helper programs.
This guide is written for Debian12 bookworm. Other Debian-based systems like Utuntu or Knoppix, a system that can run live from a USB stick without installation, should behave the same. If you use another system, some things might be different. Most notably, Debian uses APT as packet manager. Other Linux systems might use other packaging systems. For completeness, I use a 64 bit Debian 12 operating system and openjdk 17.0.11 for running Java bytecode on an X86 Acer Aspire 5742 laptop manufactured in 2009 with 240 GB SSD and 4 GB ram.
Install utilities and tools
First, update the index of your package manager
sudo apt update
wget
(not really necessary) sudo apt install wget
unzip
sudo apt install unzip
Java
sudo apt install default-jre
Python3
sudo apt install python3
nano
terminal text editor sudo apt install nano
gedit
if a graphical text editor is preferred sudo apt install gedit
screen
for running programs in the background sudo apt install screen
download BRouter
The easiest way is to download a compiled standalone release from the BRouter web releases page.
mkdir brouter-web #create new directory called brouter-web
cd brouter-web #change to new directory
wget https://github.com/nrenner/brouter-web/releases/download/0.18.1/brouter-web-standalone.0.18.1.zip #change url to the version you want to download
unzip Brouter
unzip brouter-web-standalone.*.zip
copy configuration
cp brouter-web/config.template.js brouter-web/config.js
edit configuration
If you run the server on the pc you intend to use the web interface with, then you do not have to change the configuration.
nano brouter-web/config.js
change localhost to your domain (my domain is example.com):
- replace
BR.conf.host = 'http://localhost:17777';
with BR.conf.host = 'http://example.com:17777';
- replace
BR.conf.profilesUrl = 'http://localhost:8000/profiles2/';
with BR.conf.profilesUrl = 'http://example.com:8000/profiles2/';
or BR.conf.profilesUrl = '../profiles2/';
press Ctrl-X to close, then press y and after that ENTER to save
start a simple web server
unsecure web server
(Navigate to the right directory first. All files in the current directory and all subdirectory will be accessible from the internet. You can check the current directory with the command pwd
)(all routes are sent unencrypted over the internet) python3 -m http.server 8000 &
or to run it in background even after you log out from the server screen -dm python3 -m http.server 8000
webserver (I think with local access only, but am not sure)
python3 -m http.server 8000 --bind localhost &
other webserver
You can also use a big web server like Apache or Nginx and let them restart if the server reboots, etc.
start brouter navigation engine
(connection also insecure) ./standalone/server.sh &
copy .rd5 segments
You can now place the .rd5 segments of the region in which you like to calculate routes to the segments4 directory. For example for the Shetland Islands (data is less than 1 MB)
cd segments4 && wget https://brouter.de/brouter/segments4/W5_N60.rd5 && cd ..
Or create the .rd5 files from OpenStreetMap data on your computer and copy the files in the segments4 directory.
access in browser
Visit your server at port 8000, for example with firefox-esr http://example.com:8000/brouter-web
When the page has fully loaded, press the F key to search, type in Garthspool and hit enter. This zooms to Garthspool near Leerwick on the Shetland islands.
Hit the escape key so close the search and hit the D key to start drawing a way. Click on a road in Lerwick, then klick on another road in Lerwick. Within seconds the server should calculate a route between the two points and show a ping route. Otherwise it should show an error message on the upper part of the screen. You can investigate some errors in the servers terminal and when using firefox by pressing Ctrl+Shift+E to inspect the network traffic.