How to install PostgreSQL 9.5 in Ubuntu 18.04?

I want to install PostgreSQL 9.5. But the available version is 9.6.

I only need 9.5 to build wal2json against it and test it (requirement because of AWS version).


The last supported release that includes postgresql-9.5 in its default repositories is Ubuntu 16.04. Manually download the following two files from the official Ubuntu website:

  • postgresql-client-9.5_9.5.12-0ubuntu0.16.04_amd64.deb
  • postgresql-9.5_9.5.12-0ubuntu0.16.04_amd64.deb

The two .deb files have been updated to postgresql-client-9.5_9.5.14-0ubuntu0.16.04_amd64.deb and postgresql-9.5_9.5.14-0ubuntu0.16.04_amd64.deb.

Change directories using cd to the directory containing the two .deb files that you downloaded. Run the following commands:

sudo apt install libedit2 libpq5 libssl1.0.0 postgresql-client-common zlib1g libgssapi-krb5-2 libldap-2.4-2 libpam0g libxml2 postgresql-common locales ssl-cert tzdata sysstat 
sudo apt install ./postgresql-client-9.5_9.5.12-0ubuntu0.16.04_amd64.deb ./postgresql-9.5_9.5.12-0ubuntu0.16.04_amd64.deb

Current versions of postgresql-all:

Ubuntu postgresql-all   
18.04   10     
19.10   11     
20.04   12  
20.10   12     
21.04   13   
21.10   13  
22.04   13