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.
Prerequisites
Discourse requires PostgreSQL 13; if you try to run on a newer or 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.
Setup the DB
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.
Configure Discourse
Get Discourse setup in the usual way, and then edit containers/app.yml
as follows:
-
Remove the line
- "templates/postgres.template.yml"
under thetemplates
top-level key (towards the top of the file); -
Under the
env
top-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>
-
Rebuild with
./launcher rebuild app
, and you should be good to go.