What this is
This guide explains how to install PostgreSQL (a popular relational database) on Linux.
What it is for
- Run applications that require PostgreSQL
- Use a powerful SQL database with strong features
Prerequisites
- SSH + sudo
Step-by-step by distribution
A) Ubuntu/Debian
sudo apt update
sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresql
B) CentOS/RHEL/Rocky/AlmaLinux
sudo dnf install -y postgresql-server postgresql-contrib
sudo postgresql-setup --initdb || true
sudo systemctl enable --now postgresql
Step 2) Verify service
sudo systemctl status postgresql --no-pager
Step 3) Test local access
sudo -i -u postgres psql
Expected output: postgres=# prompt.
Exit:
q
Warnings & notes
- Do not expose PostgreSQL port 5432 to the internet unless you know what you are doing.
- For remote access, use private networks/VPN and proper pg_hba.conf configuration.
Conclusion
PostgreSQL is installed and running. Next steps: create a database/user and secure remote access if needed.