My blog built with Hugo https://emanuelpina.pt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

3.3 KiB

title date draft thumbnail categories tags readmore summarize update
PostgreSQL Installation on Ubuntu 2019-12-21T11:12:04Z false v1575980873/2019/PostgreSQL.jpg [SysAdmin] [PostgreSQL Ubuntu VPS] Read the tutorial true true

On the way to install Nextcloud we've already completed the initial setup of our VPS and the installation of a webserver (Nginx).

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.

Why PostgreSQL

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.

Install PostgreSQL

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.

Tune PostgreSQL

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.

Save your changes and just restart the PostgreSQL service:

# sudo systemctl restart postgresql

What's next?

Now that you've installed a webserver and a database management system all that's missing so you can install Nextcloud is PHP.

{{< call-for-contribution >}}