So I just had to redo a DBMS instance for a project I'm working on and decided it may be helpful to put all of the postgres set up in one place!
We are going to be working with an Ubuntu instance so first set up a basic AWS Ubuntu instance!
Next we are going to go through all of these commands line by line.
$ sudo apt update
$ sudo apt upgrade
$ apt install postgresql-client
Now lets connect to the server!
$ psql -h postgre-server -U postgre-user
Next let's install postgres server!
$ sudo apt install postgresql
We can check the port we are using with this command!
$ ss -nlt
It should be the default port 5432
We can change the start up settings with either
$ sudo systemctl enable postgresql
$ sudo systemctl disable postgresql
To be able to access from a non-local machine we need to edit the postgresql.conf file
$ sudo vim /etc/postgresql/12/main/postgresql.conf
Change the line under CONNECTIONS AND AUTHENTICATIONS to
listen_addresses = '*'
Now just restart postgres with
$ sudo systemctl restart postgresql
Time to vim into another config to allow clients to connect to the database
$ sudo vim /etc/postgresql/12/main/pg_hba.conf
add this line under of all the other hosts!
host all all 0.0.0.0/0 md5
And now to make sure that the firewall doesn't stop connections to port 5432 just run this command!
$ sudo ufw allow from any to any port 5432 proto tcp
Now all that is required is to set up a user add some data and be sure to connect your client with some type of dev_config! Happy hacking!