October 30th 2023
Updated 28th November 2023
This page is a tribute to David Clinton’s instructions on how to install Nextcloud as a Snap. I recommend reading that one for more information. I’m just covering the basics here.
Update: I have added some more detailed instructions about enabling HTTPS. I have also included a new chapter with some basic Nextcloud snap management commands.
I have in the past installed Nextcloud as a jail on TrueNAS. That had mixed results; sometimes it worked, sometimes it didn’t, due to dependency hell. Also, with IPv6 and multiple routing tables, there were some serious tweaking and workarounds that needed to be done to make it stable. I spent a lot of time making it work.
After reading David Clinton’s article I decided to try the snappy way. I can’t believe what a time-saver that was! I was literally done in about 15min, instead of 3 weeks, which is the time it usually take to setup a new system.
The Snap install works great if you primarily want to backup and share files. However, the snap version does not include all the features like Collabora or Talk. However, you can add those feature later if you want.
Note: If you don’t know what Snap is, here are 2 articles about it:
Linux Tutorial #5 Part 3: Installing Applications on Linux: The Snap Packet Manager
David Clinton: Managing Ubuntu Snaps: the stuff no one tells you
Preparation: VM Properties
I’m using an Ubuntu Server 22.04 LTS with two disks;
One local small disk for /root and /boot filesystems
One large network drive for the /var filesystem. Nextcloud storage will be stored there by default.
Other hardware settings depends on the amount of users. However, my current utilization, with a few home computers connected:
Current Utilization, (Idle):
RAM Utilization: ~1GB.
CPU Utilization: ~1 core used.
Note: I haven’t checked what the utilization is when uploading/downloading huge amounts of files.
Note: According to Nextclouds Hardware Requirements, at least 512MB of RAM should be used, which I find to be a bit optimistic. I would recommend at least 2GB.
Install Instructions
Task 1: Install:
$ snap install nextcloud
$ nextcloud.manual-install admin password
Note: username will be “admin” and password will be “password” unless you change it.
Task 2: Define from which domains and IP addresses that users are allowed to access the nextcloud server on:
$ nextcloud.occ config:system:set trusted_domains 1 \
--value=nextcloud.bastuklubben.online
$ nextcloud.occ config:system:set trusted_domains 2 \
--value=10.10.9.2
$ nextcloud.occ config:system:set trusted_domains 3 \
--value=2001:DB8:1234:9011::2
Note: Configuration gets saved here:$ less /var/snap/nextcloud/current/nextcloud/config/config.php
Overview of all CLI commands:$ nextcloud.occ
Enable HTTPS
There are 3 options for enabling HTTPS:
root@sauna-pub:~/snap/nextcloud/current# nextcloud.enable-https -h
Usage:
nextcloud.enable-https -h
Display this help message.
nextcloud.enable-https <subcommand> [OPTIONS]
Run the provided subcommand.
Available subcommands:
lets-encrypt [OPTIONS]
Obtain a certificate from Let's Encrypt and automatically keep it
up-to-date.
self-signed
Generate and use a self-signed certificate. This is easier to
setup than Let's Encrypt certificates, but will cause warnings in
browsers.
custom [OPTIONS]
Use certificates generated by other means.
Let’s encrypt certificate: automatic generation of a public SSL certificate with automatic renewal.
Self-Signed certificate: Can be used when using reverse proxy for SSL offloading.
Custom: Certificate generated from your own PKI infrastructure
Enable let's encrypt SSL certificate:$ nextcloud.enable-https lets-encrypt
Note: requires that you have a subdomain defined (i.e. nextcloud.example.com).
Enable self-signed certificate:
$ nextcloud.enable-https self-signed
Note: Some Nextcloud applications require HTTPS to be enabled. It’s recommended to at least have a self-signed certificate.
Enable custom certificate:
$ nextcloud.enable-https custom certificate.pem private.key ca-chain.pem
Notes:
the certificate files needs to be put in the folder
/root/snap/nextcloud/current
There is also an optional -s flag to enable HSTS = HTTP Strict Transport Security
That’s it really, for the installation part at least. Now you should be able to reach the webGUI, start fine-tuning the configuration and add users.
Snap Management
Down below are some useful snap commands.
Change snap port numbers
If you are planning to put Nextcloud behind a reverese-proxy, you might need to change the port numbers:
sudo snap set nextcloud ports.http=81 ports.https=444
View information about Nextcloud
To see the logs:
sudo snap logs nextcloud -n 100
Note: the -n flag is to view the last 100 entries.
To see information about the nextcloud snap, like current version and available commands:
sudo snap info nextcloud
Revert to an older version
WARNING! this command also reverts configuration changes and files(!) but it helped me solve a problem:
sudo snap revert nextcloud