-
sudo su
if you are not root. -
apt install
##PostgreSQL installation We will be installing it from the official repository. -
sudo apt-get install wget ca-certificates
-
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
Now we will actually install PostgreSQL into the server.
5. sudo apt-get update
6. sudo apt-get upgrade
7. sudo apt-get install mlocate firewalld chromium-chromedriver postgresql postgresql-contrib
- `mlocate` is used to locate files in the system.
- `chromium-chromedriver` is used for the screenshot command.
-
pg_lsclusters
to see where the log is located. -
Locate these two files using
mlocate
:pg_hba.conf
postgresql.conf
-
Enter
postgresql.conf
usingnano
.- Change the listening port to
5433
. - Change the
listen_addresses = '*'
- Change the listening port to
-
Enter
pg_hba
usingnano
.-
Add a line under
#IPv4 local connections
that allow for outside users to connect. It is recommended you specify another user, not thepostgres
user.host all dankvibes 0.0.0.0/0 scram-sha-256
-
Remove the line
host all all 127.0.0.1/32 scram-sha-256
, since we already allowed connection through peer. -
Reject all incoming connections aiming for the user
postgres
from outside, by adding the linehost all postgres 0.0.0.0/0 reject
-
-
service postgresql restart
-
sudo systemctl start postgresql.service
- Make sure it's running smoothly by checking
service postgresql status
andpg_lsclusters
(especially checking the port).
- Make sure it's running smoothly by checking
-
To go to PostgreSQL shell, use
sudo -u postgres psql
-
createuser --interactive
to create a new user.- Change the password with
ALTER USER dankvibes PASSWORD 'myPassword';
- We'll use firewalld (or firewall-cmd) for it.
sudo systemctl enable firewalld
- Make sure it's running using
sudo firewall-cmd --state
-
sudo firewall-cmd --permanent --add-port=5000/tcp sudo firewall-cmd --permanent --add-port=5433/tcp sudo firewall-cmd --permanent --add-port=22/tcp sudo firewall-cmd --reload
- From then on, use the PostgreSQL shell or pgAdmin to configure, backup and restore.