Step by step to install Postgres on AWS Amazon Linux 2 instance

I found people is having difficulties when working with Amazon Linux packages because the lack of documentation, including myself !
So I write down the “dead easy” steps to install PostgresSQL on AWS Amazon Linux 2 instance.
OK, let’s go !!!

1. Update your system

sudo yum update -y

2. Enable PostgreSQL in AMZ extra repository

I’m installing PostgreSQL v11, you can change it to the version you want to use in your system

sudo amazon-linux-extras enable postgresql11
Step 2 output

3. Install Postgres & dependencies libs

Note that we don’t need version number in the install command

sudo yum install -y postgresql-libs postgresql-server postgresql postgresql-devel

4. Init Postgres DB

sudo postgresql-setup --initdb
Step 4 output

5. Start Postgres server, at this point everything is ready to use !

# Set "autostart" Postgres on system startup
sudo systemctl enable postgresql

# Start Postgres
sudo systemctl start postgresql

6. Check Postgres status

sudo systemctl status postgresql
Step 6 output

Happy tinkering !

Share this on: