Introduction
Digital Ocean has been a leader in Virtual Server provision for the masses for some time and their technical support and articles are some of the best out there. In this article we follow Alex Garnett‘s tutorial on how to setup NextCloud as a Snap service on Ubuntu 20.04.
Now, I picked up on this article purely because it is one of few decent tutorials that is based on instaling NC from a Snap as opposed to downloading a zip package and taking things from there. Now, there is a good reason for this choice and that is because I made a rare choice of choosing to install NextCloud as part of spinning up a VM with Ubuntu 24.04 Operating System. This is somewhat very odd because I have a degree of recursion of Hypervisors and Virtual Machines going on here – that is, I am running Proxmox on a Bare Metal Server with Containers and Virtual Machines as part of my farm of web servers, some with Static IP’s and others using Shared Hosting through either Apache or Nginx.
It is mind bending to think about how this is all working because this particular VM and Ubuntu 24.04 is running within Proxmox and if I had known that NC installation as an ‘option’ during Ubuntu installation was a Virtualized scheme, I would probably have avoided doing so. It was not until I completed the insstallation that I realised things were different to my usual approach to setting up my web-applications and I needed to look-up how to initiate my NC installation.
So, here is Digital Ocean technical writer’s take on how to install NC as a Snap and since I already have my instance installed, I will benefit from picking up on this tutorial from about half ay through, having verified a few checks and balances in Step 1, so I will be watching closely how to configure NC from Step 2 onwards.
Just to be complete, I already have NC running on my server and it was installed in a different way, I don’t remember distictly but I am sure it was through NC’s official channels and running as a VM on my XCP-ng (Citrix [derivative] Hypervisor) and it has been running with very few issues for over 18 months now.
The only issue I have with it is that my current instance has failed to upgrade and I am stuck on revision 27, with frequent reminders to update. I can see it deteriorating and even unofficial support for it becoming scarce each day Otherwise, I am very happy with it, the applications and synchronisation Smartphone Applications that I have become dependent on in an effort to reject becoming another number in mass technology giants. NC has become the cornerstone of my freedom and self determination about 90% independent.
Once I have this latest version of NC up and running, my next big challenge is going to be relocation of my data from old to new NC as that is tending to about 600GB now and I feel vulnerable despite taking regular Snapshots of it under XCP-ng.
Now let’s get back to Digital Ocean’s guidelines to install NC as a Snap instance.
Article Introduction
Nextcloud, a fork of ownCloud, is a file sharing server that permits you to store your personal content, like documents and pictures, in a centralized location, much like Dropbox. The difference with Nextcloud is that all of its features are open-source. It also returns the control and security of your sensitive data back to you, thus eliminating the use of a third-party cloud hosting service.
In this tutorial, we will install and configure a Nextcloud instance on an Ubuntu 22.04 server.
Prerequisites
In order to complete the steps in this guide, you will need the following:
- A non-root sudo-enabled user and firewall configured on your server: You can create a user with
sudo
privileges and set up a basic firewall by following the Initial Server Setup with Ubuntu 22.04. - (Optional) A domain name pointed to your server: We will be securing connections to the Nextcloud installation with TLS/SSL. Nextcloud can set up and manage a free, trusted SSL certificate from Let’s Encrypt if your server has a domain name. If not, Nextcloud can set up a self-signed SSL certificate that can encrypt connections, but won’t be trusted by default in web browsers. If you are using DigitalOcean, you can read our DNS documentation to learn how to add domains to your account and manage DNS records, if you intend to use Let’s Encrypt.
Once you have completed the above steps, continue on to learn how to set up Nextcloud on your server.
Step 1 – Installing Nextcloud
We will be installing Nextcloud using the Snap packaging system. This packaging system, available on Ubuntu 22.04 by default, allows organizations to ship software, along with all associated dependencies and configuration, in a self-contained unit with automatic updates. This means that instead of installing and configuring a web and database server and then configuring the Nextcloud app to run on it, we can install the snap
package which handles the underlying systems automatically.
To download the Nextcloud snap package and install it on the system, type:
sudo snap install nextcloud
The Nextcloud package will be downloaded and installed on your server. You can confirm that the installation process was successful by listing the changes associated with the snap:
snap changes nextcloud
OutputID Status Spawn Ready Summary
4 Done today at 16:12 UTC today at 16:12 UTC Install "nextcloud" snap
The status and summary indicate that the installation was completed without any problems.
Getting Additional Information About the Nextcloud Snap
If you’d like some more information about the Nextcloud snap, there are a few commands that can be helpful.
The snap info
command can show you the description, the Nextcloud management commands available, as well as the installed version and the snap channel being tracked:
snap info nextcloud
Snaps can define connections they support, which consist of a slot and plug that, when hooked together, gives the snap access to certain capabilities or levels of access. For instance, snaps that need to act as a network client must have the network
connection. To see what snap connections
this snap defines, type:
snap connections nextcloud
OutputInterface Plug Slot Notes
network nextcloud:network :network -
network-bind nextcloud:network-bind :network-bind -
removable-media nextcloud:removable-media - -
To learn about all of the specific services and apps that this snap provides, you can take a look at the snap definition file by typing:
cat /snap/nextcloud/current/meta/snap.yaml
This will allow you to see the individual components included within the snap, if you need help with debugging.
Step 2 – Configuring an Administrative Account
There are a few different ways you can configure the Nextcloud snap. In this guide, rather than creating an administrative user through the web interface, we will create one on the command line in order to avoid a small window where the administrator registration page would be accessible to anyone visiting your server’s IP address or domain name.
To configure Nextcloud with a new administrator account, use the nextcloud.manual-install
command. You must pass in a username and a password as arguments:
sudo nextcloud.manual-install sammy password
The following message indicates that Nextcloud has been configured correctly:
OutputNextcloud was successfully installed
Now that Nextcloud is installed, we need to adjust the trusted domains so that Nextcloud will respond to requests using the server’s domain name or IP address.
Step 3 – Adjusting the Trusted Domains
When installing from the command line, Nextcloud restricts the host names that the instance will respond to. By default, the service only responds to requests made to the “localhost” hostname. We will be accessing Nextcloud through the server’s domain name or IP address, so we’ll need to adjust this setting to accept these type of requests.
You can view the current settings by querying the value of the trusted_domains
array:
sudo nextcloud.occ config:system:get trusted_domains
Outputlocalhost
Currently, only localhost
is present as the first value in the array. We can add an entry for our server’s domain name or IP address by typing:
sudo nextcloud.occ config:system:set trusted_domains 1 --value=example.com
OutputSystem config value trusted_domains => 1 set to string example.com
If we query the trusted domains again, we will see that we now have two entries:
sudo nextcloud.occ config:system:get trusted_domains
Outputlocalhost
example.com
If you need to add another way of accessing the Nextcloud instance, you can add additional domains or addresses by rerunning the config:system:set
command with an incremented index number (the “1” in the first command) and adjusting the --value
.
Step 4 – Securing the Nextcloud Web Interface with SSL
Before we begin using Nextcloud, we need to secure the web interface.
If you have a domain name associated with your Nextcloud server, the Nextcloud snap can help you obtain and configure a trusted SSL certificate from Let’s Encrypt. If your Nextcloud server does not have a domain name, Nextcloud can configure a self-signed certificate which will encrypt your web traffic but won’t be automatically trusted by your web browser.
With that in mind, follow the section below that matches your scenario.
Option 1: Setting Up SSL with Let’s Encrypt
If you have a domain name associated with your Nextcloud server, the best option for securing your web interface is to obtain a Let’s Encrypt SSL certificate.
Start by opening the ports in the firewall that Let’s Encrypt uses to validate domain ownership. This will make your Nextcloud login page publicly accessible, but since we already have an administrator account configured, no one will be able to hijack the installation:
sudo ufw allow 80,443/tcp
Next, request a Let’s Encrypt certificate by typing:
sudo nextcloud.enable-https lets-encrypt
You will first be asked whether your server meets the conditions necessary to request a certificate from the Let’s Encrypt service:
OutputIn order for Let's Encrypt to verify that you actually own the
domain(s) for which you're requesting a certificate, there are a
number of requirements of which you need to be aware:
1. In order to register with the Let's Encrypt ACME server, you must
agree to the currently-in-effect Subscriber Agreement located
here:
https://letsencrypt.org/repository/
By continuing to use this tool you agree to these terms. Please
cancel now if otherwise.
2. You must have the domain name(s) for which you want certificates
pointing at the external IP address of this machine.
3. Both ports 80 and 443 on the external IP address of this machine
must point to this machine (e.g. port forwarding might need to be
setup on your router).
Have you met these requirements? (y/n)
Type y
to continue.
Next, you will be asked to provide an email address to use for recovery operations:
OutputPlease enter an email address (for urgent notices or key recovery):
Enter your email and press Enter
to continue.
Finally, enter the domain name associated with your Nextcloud server:
OutputPlease enter your domain name(s) (space-separated): example.com
Your Let’s Encrypt certificate will be requested and, provided everything went well, the internal Apache instance will be restarted to immediately implement SSL:
OutputAttempting to obtain certificates... done
Restarting apache... done
You can now skip ahead to the next step to sign into Nextcloud for the first time.
Option 2: Setting Up SSL with a Self-Signed Certificate
If your Nextcloud server does not have a domain name, you can still secure the web interface by generating a self-signed SSL certificate. This certificate will allow access to the web interface over an encrypted connection, but will be unable to verify the identity of your server, so your browser will likely display a warning.
To generate a self-signed certificate and configure Nextcloud to use it, type:
sudo nextcloud.enable-https self-signed
OutputGenerating key and self-signed certificate... done
Restarting apache... done
The above output indicates that Nextcloud generated and enabled a self-signed certificate.
Now that the interface is secure, open the web ports in the firewall to allow access to the web interface:
sudo ufw allow 80,443/tcp
You are now ready to log into Nextcloud for the first time.
Step 5 – Logging in to the Nextcloud Web Interface
Now that Nextcloud is configured, visit your server’s domain name or IP address in your web browser:
https://example.com
Note: If you set up a self-signed SSL certificate, your browser may display a warning that the connection is insecure because the server’s certificate is not signed by a recognized certificate authority. This is expected for self-signed certificates, so feel free to click through the warning to proceed to the site.
Since you have already configure an administrator account from the command line, you will be taken to the Nextcloud login page. Enter the credentials you created for the administrative user:

Click the Log in button to log in to the Nextcloud web interface.
The first time you enter, a window will be displayed with some introductory text and links to various Nextcloud clients that can be used to access your Nextcloud instance:

Click through to download any clients you are interested in, or exit out of the window by clicking the X in the upper-right corner. You will be taken to the main Nextcloud interface, where you can begin to upload and manage files:

Your installation is now complete and secured. Feel free to explore the interface to get more familiarity with the features and functionality of your new system.
Conclusion
Nextcloud can replicate the capabilities of popular third-party cloud storage services. Content can be shared between users or externally with public URLs. The advantage of Nextcloud is that the information is stored securely in a place that you control.
For additional functionality, take a look at Nextcloud’s app store, where you can install plugins to extend the service’s capabilities.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
About the author
Alex Garnett
Author
Senior DevOps Technical Writer
Former Senior DevOps Technical Writer at DigitalOcean. Expertise in topics including Ubuntu 22.04, Linux, Rocky Linux, Debian 11, and more.
Category:
Tags:
Still looking for an answer?
Ask a questionSearch for more help
Was this helpful?YesNoComments(10)Follow-up questions(0)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
May 25, 2022Show less
How can I change nextcloud entry address from example.com to nc.example.com if I have changed my mind after setting everything up?Reply(1) replies
August 1, 2022Show less
whats the point of that – as there is Nextcloud AIO https://github.com/nextcloud/all-in-one#how-to-use-thisReply(1) replies
August 15, 2022Show less
That instruction does not work, constantly getting 2006 MySQL server has gone away
error messages on manual-install stepReply(1) replies
August 22, 2022Show less
It’s probably worth mentioning in this article that snap has its own instance of Apache2 and that will conflict if your Ubuntu server is already used for hosting other sites in Apache2 (unless something like a reverse proxy is set up to direct to the apache2 instance within the NextCloud snap).
I’m back in the linux game recently and was unfamiliar with snap – went through this guide and ended up uninstalling the snap pkg and installing NextCloud via traditional means because of the conflict.Reply(1) replies
November 4, 2022Show less
I have tried in different ways pero I can not install smbclient since it is in another environment to install it by snap How you can fix that problemReply(1) replies
February 20, 2023Show less
On a new DO droplet running Ubuntu 22.04, I get this error when using the nextcloud.manual-install username pwd
command:
MySQL username and/or password not valid You need to enter details of an existing account.
Reply(1) replies
June 29, 2023Show less
After rebooting the server I run into the same issue as many; nextcloud is not reachable anymore. The two suggested methods of 1) disabling the firewall or 2) stopping apache2 both don’t work.
If SO many folks run into this, why isn’t there a simple instruction to fix this?Reply(1) replies
July 20, 2023Show less
I’m not sure hot to get an answer. To become part of the community you need a cc or paypal, like most in the world I have neither. Still I’m looking for answers;
- The latest snap nextcloud solution cannot send e-mail, it won’t allow to send testmail; (worked before)
- once you reboot the server, nextcloud instance never comes back. I’m not the only one reporting, why is nothing been done? Or am I missing the answers?
Reply(1) replies
July 26, 2023Show less
Hi, For information, on Step 2, I got this message
sudo nextcloud.manual-install xxx yyy
[1] 60243
Command 'dre' not found, did you mean:
command 'dpe' from deb delly (0.9.1-1)
command 'dreg' from deb emboss (6.6.0+dfsg-11ubuntu1)
command 'tre' from deb tre-command (0.3.6-2)
command 'drc' from deb drc (3.2.3~dfsg0-1build1)
command 're' from deb re (0.1-7build1)
command 'due' from deb due (3.0.0-1)
command 'dte' from deb dte (1.10-1)
Try: sudo apt install <deb name>
I’m not sure what program the command “dre” calls, but the install seems to have been successful. Any clues?Reply(1) replies
July 31, 2023Show less
Excellent tutorial. Could you please write an ammendment to this which explains how to set up NextCloud Office (the bundled package) so that it works behind a reverse proxy? I am running Apache+Wordpress on a Ubuntu server and I want to run Snap NextCloud in parallel to the existing Apache+WP install. I did figure out how to get Nextcloud to run via a Snap install but NextCloud office fails to start/edit a document because of mixed http/https data. It appears that the Office software is serving http while the rest of Nextcloud is serving out https.Reply
By Alex Garnett How To Install and Configure Nextcloud on Ubuntu 22.04
Senior DevOps Technical Writer