Database Setup
This guide covers the installation and configuration of PostgreSQL and Redis, which provide data storage and caching for Surfly.
PostgreSQL Configuration
Section titled “PostgreSQL Configuration”You’ll need PostgreSQL version 16 with two databases: surfly and console.
Install PostgreSQL server using your system’s package manager:
# RHEL/CentOS/Fedorasudo dnf install postgresql-server -yCreate a dedicated database user for Surfly with CREATEDB privileges:
sudo -u postgres psql -c "CREATE ROLE surfly_app WITH LOGIN CREATEDB;"Create the required databases with UTF-8 encoding:
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;"Configure Authentication
Section titled “Configure Authentication”First, locate the PostgreSQL host-based authentication configuration file:
sudo -u postgres psql -c "SHOW hba_file;"Edit the returned file path:
sudo vim [path_to_hba_file] # Replace with actual path from aboveAdd the following lines above the existing default rules:
local all surfly_app trusthost all surfly_app 127.0.0.1/32 trust
# Default rules (existing)local all all peerhost all all 127.0.0.1/32 scram-sha-256host all all ::1/128 scram-sha-256Restart PostgreSQL to apply changes:
sudo systemctl restart postgresqlRedis Setup
Section titled “Redis Setup”Install Redis server using your system’s package manager:
# RHEL/CentOS/Fedorasudo dnf install redis -yVerify the installation:
sudo systemctl status redisTest Redis connectivity:
redis-cli ping# Expected response: PONG