Configure Kolibri for production environments with PostgreSQL, systemd, and production-optimized settings
Production deployments require additional configuration for performance, reliability, and security. This guide covers PostgreSQL setup, systemd integration, and production best practices.
-- Create databaseCREATE DATABASE kolibri;-- Create user with passwordCREATE USER kolibri_user WITH PASSWORD 'secure_password_here';-- Grant privilegesGRANT ALL PRIVILEGES ON DATABASE kolibri TO kolibri_user;-- Grant schema privileges (PostgreSQL 15+)\c kolibriGRANT ALL ON SCHEMA public TO kolibri_user;-- Exit psql\q
The default-serializable alias provides SERIALIZABLE isolation for critical operations.
SQLite uses custom database routers for splitting sessions, notifications, and sync queues into separate database files. PostgreSQL stores all data in a single database.
Kolibri includes a Make target for testing with a temporary PostgreSQL instance:
# Run tests with PostgreSQL backendmake test-with-postgres# Start Kolibri in foreground with PostgreSQLmake start-foreground-with-postgres
This uses Docker Compose to spin up a temporary PostgreSQL container:
# From Makefileexport KOLIBRI_DATABASE_ENGINE=postgresexport KOLIBRI_DATABASE_NAME=defaultexport KOLIBRI_DATABASE_USER=postgresexport KOLIBRI_DATABASE_PASSWORD=postgresexport KOLIBRI_DATABASE_HOST=127.0.0.1export KOLIBRI_DATABASE_PORT=15432docker compose up --detach# ... wait for database to be ready ...make testdocker compose down -v
This is for testing purposes only. The database volume is ephemeral and destroyed after tests complete.
[Unit]Description=Kolibri Learning PlatformAfter=network.target postgresql.serviceRequires=postgresql.service[Service]Type=notifyUser=kolibriGroup=kolibriEnvironment="KOLIBRI_HOME=/var/kolibri"Environment="KOLIBRI_DATABASE_ENGINE=postgres"Environment="KOLIBRI_DATABASE_NAME=kolibri"Environment="KOLIBRI_DATABASE_USER=kolibri_user"Environment="KOLIBRI_DATABASE_PASSWORD=secure_password_here"Environment="KOLIBRI_DATABASE_HOST=localhost"# Run migrations before starting serverExecStartPre=/usr/local/bin/kolibri configure setup# Start server with --skip-update to avoid timeoutExecStart=/usr/local/bin/kolibri start --skip-updateExecStop=/usr/local/bin/kolibri stopRestart=on-failureRestartSec=10# Security hardeningNoNewPrivileges=truePrivateTmp=trueProtectSystem=strictProtectHome=trueReadWritePaths=/var/kolibri[Install]WantedBy=multi-user.target
sudo systemctl status kolibrisudo journalctl -u kolibri -f
Use --skip-update flag with kolibri start to prevent systemd timeout during database migrations. Run kolibri configure setup separately in ExecStartPre to handle one-time setup steps.
# Check if server is respondingcurl http://localhost:8080/# Check systemd statussystemctl status kolibri# View recent logsjournalctl -u kolibri -n 100 --no-pager