Install PostgreSQL for Linux

Install PostgreSQL directly on a Linux server or via a Docker image for use with CAST Imaging

Overview

You can install an official PostgreSQL installation:

  • either direct on your Linux server
  • or via a Docker image.

See the installation instructions below.

Supported PostgreSQL releases

See What are the database requirements?

Installation

Direct install on Linux server

Your chosen Linux distribution may include a specific release of PostgreSQL by default but that may not be the latest available release nor one that is supported by CAST (see What are the database requirements?). CAST recommends PostgreSQL 18.x. You can use the official PostgreSQL repository for your distribution’s package manager system to install the specific release you need:

Distribution Instructions
Ubuntu via APT PostgreSQL for Ubuntu external link
Debian via APT PostgreSQL for Debian external link
Red Hat (RHEL/Rocky/Alma/CentOS) via Yum or DNF PostgreSQL for Red Hat family distributions external link

Server encoding

CAST Imaging requires the UTF8 encoding (see Requirements for the database user and encoding). On Linux, PostgreSQL takes the encoding from the environment locale when the cluster is created (LC_ALL, then LC_CTYPE, then LANG): a *.UTF-8 locale gives UTF8, but the C / POSIX locale, or no locale at all (common on minimal and cloud images), gives SQL_ASCII. Databases inherit the cluster encoding, so check it immediately after installation:

$ sudo -u postgres psql -c "SHOW server_encoding;"

If the result is not UTF8, recreate the cluster with an explicit encoding before it holds any data:

  • Debian/Ubuntu:

    $ sudo pg_dropcluster --stop <version> main
    $ sudo pg_createcluster <version> main --encoding=UTF8 --locale=C --start
    
  • Red Hat family (empty the data directory first if a cluster was already initialized):

    $ sudo PGSETUP_INITDB_OPTIONS="--encoding=UTF8 --locale=C" /usr/pgsql-<version>/bin/postgresql-<version>-setup initdb
    

Install via a Docker image

See https://hub.docker.com/_/postgres external link for more information about how to install an official PostgreSQL image on Docker.

What next?

See Post installation information and action items.