Installation from sources
This page describes how to install the application from its GIT sources on Debian.
Prerequisites
- Debian 12 or 13 (OS)
- PostgreSQL + PostGIS 3 + hstore + pgrouting
- Python 3
- Node.js (front build) + npm
- A reverse proxy (Nginx) in production
Updating the system and installing the necessary utilities
$ sudo apt update && sudo apt upgrade
$ sudo apt install -y curl dos2unix git openssl
Cloning the LeBonTag v2 git repository
$ sudo git config --global user.email ‘XXXX’
$ cd /opt && sudo git clone --branch main https://gitlab.com/Geonov/lebontag-v2.git
Where XXXX should be replaced with the server administrator's email address.
Proxy (optional)
If your organisation uses a proxy, you must specify the ‘http_proxy’ and ‘https_proxy’ environment variables so that Python can access the Internet.
/etc/environment file:
http_proxy=http://***:***
https_proxy=http://***:***
Contab file via ‘sudo crontab -e’:
http_proxy=http://***:***
https_proxy=http://***:***
Database
Schemas
Loading the data model
- Create an ‘osm’ role in PostgreSQL.
- Create a PostgreSQL database owned by ‘osm’ with the Postgis (v3), hstore and pgrouting extensions.
- Run the script /opt/lebontag-v2/sql/lebontag_v2.sql inside the new ‘osm’ database with the ‘osm’ user: tables in the ‘public’ and “lebontag” schemas will be created, with ‘OWNER TO osm’ on the various objects.
Schemas created
- lebontag: application schema
- osm2pgrouting: OSM data split by pgRouting
- osm2pgsql: OSM data loaded by osm2pgsql
Dependencies
OSM
$ sudo apt install -y --no-install-recommends osmctools gdal-bin osmium-tool
Version 2.2.0 of osm2pgsql must be installed. It is compiled from source to ensure that the correct version is used:
$ sudo apt remove -y osm2pgsql
$ sudo apt install -y make cmake g++ libboost-dev libexpat1-dev zlib1g-dev libpotrace-dev libopencv-dev libbz2-dev libpq-dev libproj-dev lua5.3 liblua5.3-dev pandoc nlohmann-json3-dev pyosmium libluajit-5.1-dev
$ cd /usr/local/src/
$ sudo wget https://github.com/osm2pgsql-dev/osm2pgsql/archive/refs/tags/2.2.0.tar.gz
$ sudo tar -xvzf 2.2.0.tar.gz
$ cd /usr/local/src/osm2pgsql-2.2.0
$ sudo mkdir build && cd build
$ sudo cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -D WITH_LUAJIT=O -Wno-dev
$ sudo make
$ sudo make install
Test:
$ /usr/local/bin/osm2pgsql -V
Python (virtual environment)
$ sudo apt install -y python3 python3-pip libpq-dev python3-venv python3-dev
$ cd /opt/lebontag-v2 && python3 -m venv .venv
$ source .venv/bin/activate
$ pip install --upgrade pip
$ python3 -m pip install -r /opt/lebontag-v2/python/requirements.txt
$ deactivate
Infos: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/
NodeJS
- v22 (Debian 12)
$ sudo bash
$ curl -o- https://fnm.vercel.app/install | bash
$ source /root/.bashrc
$ fnm install 22
- v25 (Debian 13)
$ sudo bash
$ curl -o- https://fnm.vercel.app/install | bash
$ source /root/.bashrc
$ fnm install 25
- Verifications
$ node -v
$ npm -v
NodeJS modules
$ cd /opt/lebontag-v2 && npm --loglevel verbose install && npm update --loglevel verbose
LeBonTag v2
Configuration
$ cp .env.production.local.example .env.production.local
Edit the .env.production.local file:
Database connection
- DB_HOST: host
- DB_PORT: port
- DB_NAME: database name
- DB_USER: role
- DB_PASS: password
- DB_SCHEMA=lebontag: schema (do not modify)
- DB_SRID=4326: coordinate system (do not modify)
Authentication
- AUTH_URL: Application URL
- AUTH_TRUST_HOST=true: Do not modify
- AUTH_DEBUG: Debug mode
- AUTH_SECRET: Unique installation hash. Use
openssl rand -hex 32to generate one.
Finally, you must configure at least one external authentication provider. See the URLs for each one listed in the file.
- AUTH_XXX_ID: ID of authentication provider XXX
- AUTH_XXX_SECRET: Secret of authentication provider XXX
Additional providers can be added in the /src/auth.ts file (advanced).
Compilation
- Via sudo:
$ cd /opt/lebontag-v2/ && sudo npx next telemetry disable
$ sudo npm run lint && sudo npm run build --omit=dev
$ sudo dos2unix /opt/lebontag-v2/scripts/*.sh && sudo chmod +x /opt/lebontag-v2/scripts/*.sh
$ sudo dos2unix /opt/lebontag-v2/cron/*.sh && sudo chmod +x /opt/lebontag-v2/cron/*.sh
LeBonTag service
$ cd /opt/lebontag-v2/ && sudo npm install -g pm2@latest
$ sudo pm2 start npm -n LeBonTagv2 -- start && sudo pm2 startup systemd && sudo pm2 save
Nginx
$ apt install -y nginx
Copy the nginx-80.conf file or the nginx-443.conf file to listen on port 80 (http) or 443 (https, certificate required in this case) respectively.
$ cp /opt/lebontag-v2/nginx/nginx-80.conf /etc/nginx/sites-available/lebontag.conf
or
$ cp /opt/lebontag-v2/nginx/nginx-433.conf /etc/nginx/sites-available/lebontag.conf
Edit the file /etc/nginx/sites-available/lebontag.conf:
- Replace all instances of [WEB_SITE_URL] with the server's domain name, for example: www.lebontag.fr
- Replace [CERTIFICATE.crt] and [KEY.key] with the names of the certificate files.
Activate the configuration:
$ sudo rm /etc/nginx/sites-enabled/default
$ sudo ln -s /etc/nginx/sites-available/lebontag.conf /etc/nginx/sites-enabled/
Reload the Nginx configuration:
$ systemctl reload nginx
The application's web interface is now operational.