You can install Nextcloud on Ubuntu 22.04 in just a few steps. Setting up as an ad­min­is­tra­tor and adding the SSL cer­tifi­cate are easily done using the command line. This lets you access the interface via a web browser with the necessary security measures.

Nextcloud on Ubuntu 22.04

Nextcloud is a freely available ownCloud fork. The cloud-based data storage enables self-hosting for private or business use. Compared to Nextcloud al­ter­na­tives, the solution is par­tic­u­lar­ly im­pres­sive due to its ease of use, high stability and numerous useful security features providing optimum pro­tec­tion for your data. The in­stal­la­tion of Nextcloud on Ubuntu 22.04 requires just a few steps. In this guide, we’ll show you how to secure your data storage using SSL cer­tifi­cates right from the start.

Tip

This guide shows you how to install Nextcloud on Ubuntu 22.04. To set up Nextcloud on Debian 12, have a look at our Digital Guide. We also have a guide for in­stalling Nextcloud on Docker.

What re­quire­ments must be met?

To install Nextcloud on Ubuntu 22.04, you need to meet a few pre­req­ui­sites. First, ensure you have a server running Ubuntu 22.04. It is essential to set up a firewall. Ad­di­tion­al­ly, you must have a user with Sudo priv­i­leges. The minimum system re­quire­ments include at least 1 gigabyte of RAM and a CPU. However, for optimal per­for­mance with all add-ons, 4 gigabytes of RAM and two CPUs are rec­om­mend­ed. If you have Apache2 installed, remove it before pro­ceed­ing with the next steps. It’s also advisable to set up a domain name that points to the server in advance.

Update the system

Before com­menc­ing with the actual in­stal­la­tion, it’s important to update your system to the latest version. To do this, use the following commands:

sudo apt-get update
sudo apt-get upgrade
bash

Once Ubuntu 22.04 has been suc­cess­ful­ly updated, you can begin with the in­stal­la­tion.

In­stalling Nextcloud on Ubuntu 22.04

To install Nextcloud on Ubuntu 22.04, you can use the Snap package manager, which comes pre-installed. Snap ensures you always get the latest version and hosts all necessary files centrally. Use it to download the Nextcloud package:

sudo snap install nextcloud
bash

The current version of Nextcloud will now be down­loaded and installed. To verify whether the in­stal­la­tion was suc­cess­ful, use the following command:

snap changes nextcloud
bash

Create ad­min­is­tra­tive user

You can create an ad­min­is­tra­tive user via the interface, but this poses a security risk. To avoid exposing the reg­is­tra­tion page, create the admin directly from the command line. Use the following command, replacing “user” and “password” with your desired username and a strong password:

sudo nextcloud.manual-install user password
bash

You should then receive con­fir­ma­tion that the user has been suc­cess­ful­ly set up with ad­min­is­tra­tion rights.

Change PHP settings

To change the PHP settings, es­pe­cial­ly for larger projects, it’s a good idea to adjust the shared working memory to ensure the necessary resources are available. You can do this directly from the command line with the following command:

sudo snap set nextcloud php.memory-limit=Limit
bash

Replace the place­hold­er “Limit” using a real number.

Define trusted domains and release ports

When in­stalling via the command line, Nextcloud au­to­mat­i­cal­ly limits access to the local host only. To access the cloud solution via your domain name or IP address, you must update the con­fig­u­ra­tion. First, check the stored domains with the following command:

sudo nextcloud.occ config:system:get trusted_domains
bash

At present, only the entry “localhost” should be listed in the output. To change this, use the following command:

sudo nextcloud.occ config:system:set trusted_domains 1 --value=example
bash

Replace the place­hold­er “example” with your domain or the IP address of your server. Then, use the previous command again to check the updated entries. The new address should now appear alongside “localhost”.

It’s important that you enable ports 80 (for HTTP) and 443 (for HTTPS) in your server’s firewall:

sudo ufw allow 80, 443/tcp
bash

Set up SSL cer­tifi­cate

After in­stalling Nextcloud on Ubuntu 22.04, you can secure your data with an SSL cer­tifi­cate and enable access via HTTPS. You can either use a cer­tifi­cate from Let’s Encrypt or sign one yourself. Below, you’ll see both options, starting with the ready-made cer­tifi­cate. Ensure the necessary ports are enabled. Now, request the cer­tifi­cate with this command:

sudo nextcloud.enable-https lets-encrypt
bash

You’ll receive the following output:

In 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 that you need to be aware of:
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)
bash

Confirm using [y].

Enter your email address and confirm with [Enter]. Then, enter the domain as­so­ci­at­ed with your Nextcloud server. The cer­tifi­cate will be created and stored directly on the server.

You can also create your own cer­tifi­cate. But browsers often display a warning message because the cer­tifi­cate hasn’t been verified by an external authority. If you still want to create it, use the following command:

sudo nextcloud.enable-https self-signed
bash

You should now receive a con­fir­ma­tion and then open the ports listed above, if you haven’t already done so.

First login

Your in­stal­la­tion of Nextcloud on Ubuntu 22.04 is complete. Now open your browser and navigate to your domain or IP address. Since you’ve already created an ad­min­is­tra­tor, you’ll be taken directly to the login page. Enter the ad­min­is­tra­tor username and password. If the login is suc­cess­ful, a pop-up will display apps com­pat­i­ble with Nextcloud. You can choose to download these apps or skip this step. You’ll then be taken to the Nextcloud interface, ready for use.

Go to Main Menu