Skip to content

Database Setup

This guide covers the installation and configuration of PostgreSQL and Redis, which provide data storage and caching for Surfly.

You’ll need PostgreSQL version 16 with two databases: surfly and console.

Install PostgreSQL server using your system’s package manager:

Terminal window
# RHEL/CentOS/Fedora
sudo dnf install postgresql-server -y

Create a dedicated database user for Surfly with CREATEDB privileges:

Terminal window
sudo -u postgres psql -c "CREATE ROLE surfly_app WITH LOGIN CREATEDB;"

Create the required databases with UTF-8 encoding:

Terminal window
sudo -u postgres psql -c "CREATE DATABASE surfly WITH ENCODING 'UTF8' OWNER surfly_app;"
sudo -u postgres psql -c "CREATE DATABASE console WITH ENCODING 'UTF8' OWNER surfly_app;"

First, locate the PostgreSQL host-based authentication configuration file:

Terminal window
sudo -u postgres psql -c "SHOW hba_file;"

Edit the returned file path:

Terminal window
sudo vim [path_to_hba_file] # Replace with actual path from above

Add the following lines above the existing default rules:

local all surfly_app trust
host all surfly_app 127.0.0.1/32 trust
# Default rules (existing)
local all all peer
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256

Restart PostgreSQL to apply changes:

Terminal window
sudo systemctl restart postgresql

Install Redis server using your system’s package manager:

Terminal window
# RHEL/CentOS/Fedora
sudo dnf install redis -y

Verify the installation:

Terminal window
sudo systemctl status redis

Test Redis connectivity:

Terminal window
redis-cli ping
# Expected response: PONG