PostgreSQL Installation on Ubuntu
We’ll now proceed with the installation of PostgreSQL, a relational database management system.
I’m currently using Ubuntu 18.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 we 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 our disposale.
To do so, we can visit PGTune, fill the form with our 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 10 of PostgreSQL, I use the following command to edit it:
# sudo nano /etc/postgresql/10/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 we have installed a webserver and a database management system all that’s missing so we can install Nextcloud is PHP.