The way to an own clowd - Part 2
The way to an own clowd (part 2) - The right database
Today I’m following up on my article from Monday and showing you how to set up one of the most essential building blocks for your own cloud: PostgreSQL.
PostgreSQL - often simply called “Postgres” - is one of the most powerful and popular open source databases. It’s the perfect foundation for many services you might want to run on your own server. Whether it’s Nextcloud, Wiki.js, or Gitea: Postgres is usually the first choice when it comes to reliability, speed, and flexibility.
In this article, I’ll walk you step-by-step through installing, securing, and preparing PostgreSQL on a Debian server for use with other services.
The Right Database
Before you install PostgreSQL, it’s best to add the official package sources first to ensure you always get the latest version.
To do this, run the following commands:
# Update package lists
sudo apt update
# Install necessary tools (curl, certificates, GnuPG)
sudo apt install curl ca-certificates gnupg -y
# Download and store the PostgreSQL GPG key for package verification
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
# Add the official PostgreSQL repository to your sources
echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
# Update package lists again (now including PostgreSQL repo)
sudo apt update
You can now install and set up PostgreSQL with:
sudo apt install postgresql postgresql-contrib -y
To check if PostgreSQL is running, you can either run:
sudo systemctl status postgresql
Or start the psql
query tool:
sudo -i -u postgres psql
If you run the following SQL statement:
SELECT version();
You’ll see the current version of your running server (as of this guide, that’s usually version 17).
Quick & Dirty
sudo apt update
sudo apt install curl ca-certificates gnupg -y
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt install postgresql postgresql-contrib -y
sudo systemctl status postgresql
Conclusion
With PostgreSQL, the heart of your own cloud infrastructure is now installed.
Thanks to the official package repositories, the installation is quick and straightforward.
In the next part, coming up this Monday, I’ll show you how to make your services reliably accessible on the internet for the future.
Until then, I’d love to hear your feedback and appreciate any shares 🙏