PostgreSQL Installation on Ubuntu
We’ll now proceed with the installation of PostgreSQL, a relational database management system.
I’m currently using Ubuntu 20.04, but these instructions are equally valid for other Ubuntu versions.
PostgreSQL isn’t the obvious choice to use with Nextcloud. In fact, the officially recommended database management system by Nextcloud is MySQL or MariaDB.1
I choosed PostgreSQL mainly because I planned to run other applications, in the same server, that are only compatible with it. My goal was to have a simple as possible setup, avoiding run multiple database systems simultaneously.
Either way, PostgreSQL has its advantages like an extensive SQL compliance, data integrity and being open source and community driven.
But maybe it isn’t the right choice for you and for a more informed decision you can, for example, read this comparassion between SQLite vs MySQL vs PostgreSQL. I found it really usefull.
Ubuntu’s default repositories contain PostgreSQL packages, so you can install these using the
apt packaging system.
First, refresh the local package index:
# sudo apt update
Then, install the PostgreSQL package along with a
-contrib package that adds some additional utilities and functionality:
# sudo apt install postgresql postgresql-contrib
To learn the basics about using PostgreSQL you can start by reading this tutorial on Digital Ocean.
One of the downsides of PostgreSQL is its memory performance, so besides optional is highly recommended tune its settings depending on the hardware at your disposale.
To do so, you can visit PGTune, fill the form with your system informations and get a list of settings to add/modify in
postgresql.conf. This file can be found in
/etc/postgresql/<version_number>/main folder. In my case, as I’m using the version 12 of PostgreSQL, I use the following command to edit it:
# sudo nano /etc/postgresql/12/main/postgresql.conf
Then is a matter of search for each one of the parameters in the list and modify or add it to match the values generated by PGTune.
Now that you’ve installed a webserver and a database management system all that’s missing so you can install Nextcloud is PHP.
Do you want contribute and add something to this tutorial? Have you found a typo, grammar or formatting error? Please, feel free to edit this post and open a pull resquest.