PostgreSQL 12 instead of MariaDB/MySQL

You can find a Nextcloud installation script at github – the script will install Nextcloud 16 on Ubuntu 18.04.x (64Bit) with NGINX (TLS 1.3), PHP 7.4.x, PostgreSQL 12.x, Redis, fail2ban and ufw fully automated in less than 15 minutes! Or operate manually following the instructions below.


Install Postgresql:

cd /etc/apt/sources.list.d
echo "deb [arch=amd64] bionic-pgdg main" | tee psql.list
wget --quiet -O - | sudo apt-key add -
apt update && apt install postgresql-12 php7.4-pgsql -y

Create the databse, databse user and grant permissions:

sudo -u postgres psql <<END
CREATE USER nextcloud WITH PASSWORD 'nextcloud';

Restart the relevant services:

service postgresql restart && service php7.4-fpm restart

Tune Postgresql using

You don’t know the amount of CPUs and RAM?:

cat /proc/cpuinfo | grep processor | wc -l
grep MemTotal /proc/meminfo

or issue

sudo htop

and ammend your

vi /etc/postgresql/12/main/postgresql.conf

with the calculated values. Then restart Postgresql

service postgresql restart

Enjoy your personal data in your secured and hardened Nextcloud-Server!

Don’t forget to backup your Nextcloud

Find more instructions here: Nextcloud Backup and Restore

Carsten Rieger

Carsten Rieger

Carsten Rieger is a senior system engineer in full-time and also working as an IT freelancer. He is working with linux environments for more than 15 years, an Open Source enthusiast and highly motivated on linux installation and troubleshooting. Mostly working with Debian/Ubuntu Linux, Nginx and Apache web server, MariaDB/MySQL/PostgreSQL, PHP, Cloud infrastructure (e.g. Nextcloud) and other open source projects (e.g. Roundcube) and in voluntary work for the Dr. Michael & Angela Jacobi Stiftung for more than 7 years.