How to Install Postgresql 11 in Amazon Linux AMI?

Looks like there's no PostgreSQL 11 pre-built binary distribution for Amazon Linux. The way I solve it was to build from source code:

wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz

tar zxvf postgresql-11.5.tar.gz

cd postgresql-11.5

./configure --without-readline

make

make install

By default, it will install pg_dump into /usr/local/pgsql/bin/pg_dump.


The key was the PGDG is no longer available to Amazon Linux's yum since 9.3 so the individual pieces must be installed.

  # Remove old Postgres
  yum remove -y postgresql postgresql-server

  # Install Postgres 11
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-libs-11.4-1PGDG.rhel6.x86_64.rpm
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-11.4-1PGDG.rhel6.x86_64.rpm
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-server-11.4-1PGDG.rhel6.x86_64.rpm

[edit] Replace the 11.4 in each link above with any version you need available at https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/


sudo yum update
sudo amazon-linux-extras install postgresql11

This is an extended version of @nitsujri answer. I can't comment their comment, so I will create new answer here.

Install prerequisites:

sudo yum install readline-devel
sudo yum group install "Development Tools"

Download PostgreSQL source code and install the distro:

wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure
make
sudo make install

Add this line to your ~/.bashrc. After that relogin to an EC2 instance.

export PATH=/usr/local/pgsql/bin:$PATH