How to Install PostgreSQL 12 on Ubuntu 18.04
Update Server
Login as root to the server, then update the server and reboot.
$ apt-get update -y
$ reboot
Install the required packages.
$ apt-get install perl git nano wget -y
Install Firewall
In this Firewall we use Config Security & Firewall (CSF).
$ cd /usr/src
$ wget https://download.configserver.com/csf.tgz
$ tar -xzf csf.tgz
$ cd csf/
$ install.sh
Edit csf.conf and change the make TESTING value to 0.
$ nano /etc/csf/csf.conf
make TESTING=’0’
Save dan exit.
Reload csf with the command below.
$ csf -r
Add Repository PostgreSQL 12
Add the postgresql 12 repository to the pgdg.list, as the default is still version 10.
$ wget –quiet -O – https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add –
$ echo “deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main” |sudo tee /etc/apt/sources.list.d/pgdg.list
Update packages.
$ apt-get update -y
Install PostgreSQL 12
If you have added the repository, don't forget to update the package server to be more up-to-date, after that run the postgresql installation command as below.
$ apt-get install postgresql-12 -y
Jika sudah, start dan enable on-boot.
$ systemctl enable postgresql-12
$ systemctl start postgresql-12
And check its status whether it is active or not.
$ systemctl status postgresql-12
● postgresql-12.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql-12.service; enabled; vendor preset: enabled) Active: active (exited) since Sat 2021-11-06 10:38:45 UTC; 2 weeks 5 days ago Main PID: 1978 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 2360) CGroup: /system.slice/postgresql-12.service