Let’s say you’re using AWS RDS, or an existing PostgreSQL server managed elsewhere. It’s fairly straightforward to get Discourse to use such a setup, without needing to grant superuser privileges to anything that Discourse itself runs. Here’s how.
Discourse requires PostgreSQL 13 or later; if you try to run on an older version, it might work, but we don’t guarantee it, and if something breaks in the future, you get to keep both pieces. We also require some extensions that are distributed in the
postgresql-contrib package (or its equivalent).
Randomly generate a password for the connection (20+ characters). In this guide, we’ll use
s3kr1t as a placeholder.
As a database superuser, run the following:
CREATE USER discourse PASSWORD 's3kr1t'; CREATE DATABASE discourse OWNER discourse; \c discourse CREATE EXTENSION hstore; CREATE EXTENSION pg_trgm;
That’s all that has to be done to prepare the DB for use by Discourse.
Get Discourse setup in the usual way, and then edit
containers/app.yml as follows:
Remove the line
- "templates/postgres.template.yml"under the
templatestop-level key (towards the top of the file);
envtop-level key, set the following:
DISCOURSE_DB_USERNAME: discourse DISCOURSE_DB_PASSWORD: s3kr1t DISCOURSE_DB_HOST: <IP or hostname> DISCOURSE_DB_NAME: discourse
You also need to set the following if your database doesn’t use the default port (5432):
DISCOURSE_DB_PORT: <port> DISCOURSE_DB_BACKUP_PORT: <port>
./launcher rebuild app, and you should be good to go.