https://techviewleo.com/how-to-install-postgresql-database-on-ubuntu/
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo -u postgres psql -c "SELECT version();"
https://www.vultr.com/docs/how-to-install-the-postgis-extension-for-postgresql/
sudo apt install postgis postgresql-14-postgis-3
psql postgres -c "CREATE DATABASE federico_pg WITH ENCODING 'UTF8' TEMPLATE template0"
psql federico_pg
Ricordarsi di installare l'estensione PostGIS sul DB che si vuole utilizzare https://www.postgresqltutorial.com/postgresql-administration/psql-commands/
Connettersi al database
psql -d database -U user -WCREATE EXTENSION postgis;Creare Username e Database
su - postgres
createuser --interactive --pwpromptReplace user with the name of the user that you want to own the database, and replace dbname with the name of the database that you want to create:
createdb -O user dbname
Per impostare le configurazioni di postgres perchè sia accessibile da altri IP bisogna editare i settaggi nel file pg_hba.conf e nel file postgresql.conf presenti nella cartella etc/postgresql/14/main
cd etc/postgresql/14/main
nano pg_hba.conf
aggiungere:
host all all 0.0.0.0/0 md5
nel file postgresql.conf andare ad editare nel seguente modo:
nano postgresql.conf
listen_addresses = '*'
Riavviare il servizio Postgres con service postgresql restart
To tune up postgresql see here