Skip to content

Latest commit

 

History

History
79 lines (51 loc) · 1.75 KB

File metadata and controls

79 lines (51 loc) · 1.75 KB

INSTALLARE POSTGRESQL E POSTGIS

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();"

Installare PostGIS

https://www.vultr.com/docs/how-to-install-the-postgis-extension-for-postgresql/

sudo apt install postgis postgresql-14-postgis-3

Creare un DB

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 -W
CREATE EXTENSION postgis;

Creare Username e Database

su - postgres
createuser --interactive --pwprompt

Replace 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 

TIPS

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