How to install Nextcloud on Ubuntu 22.04
You can install Nextcloud on Ubuntu 22.04 in just a few steps. Setting up as an administrator and adding the SSL certificate 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 alternatives, the solution is particularly impressive due to its ease of use, high stability and numerous useful security features providing optimum protection for your data. The installation 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 certificates right from the start.
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 installing Nextcloud on Docker.
What requirements must be met?
To install Nextcloud on Ubuntu 22.04, you need to meet a few prerequisites. First, ensure you have a server running Ubuntu 22.04. It is essential to set up a firewall. Additionally, you must have a user with Sudo privileges. The minimum system requirements include at least 1 gigabyte of RAM and a CPU. However, for optimal performance with all add-ons, 4 gigabytes of RAM and two CPUs are recommended. If you have Apache2 installed, remove it before proceeding 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 commencing with the actual installation, 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
bashOnce Ubuntu 22.04 has been successfully updated, you can begin with the installation.
Installing 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
bashThe current version of Nextcloud will now be downloaded and installed. To verify whether the installation was successful, use the following command:
snap changes nextcloud
bashCreate administrative user
You can create an administrative user via the interface, but this poses a security risk. To avoid exposing the registration 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
bashYou should then receive confirmation that the user has been successfully set up with administration rights.
Change PHP settings
To change the PHP settings, especially 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
bashReplace the placeholder “Limit” using a real number.
Define trusted domains and release ports
When installing via the command line, Nextcloud automatically limits access to the local host only. To access the cloud solution via your domain name or IP address, you must update the configuration. First, check the stored domains with the following command:
sudo nextcloud.occ config:system:get trusted_domains
bashAt 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
bashReplace the placeholder “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
bashSet up SSL certificate
After installing Nextcloud on Ubuntu 22.04, you can secure your data with an SSL certificate and enable access via HTTPS. You can either use a certificate from Let’s Encrypt or sign one yourself. Below, you’ll see both options, starting with the ready-made certificate. Ensure the necessary ports are enabled. Now, request the certificate with this command:
sudo nextcloud.enable-https lets-encrypt
bashYou’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)
bashConfirm using [y].
Enter your email address and confirm with [Enter]. Then, enter the domain associated with your Nextcloud server. The certificate will be created and stored directly on the server.
You can also create your own certificate. But browsers often display a warning message because the certificate 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
bashYou should now receive a confirmation and then open the ports listed above, if you haven’t already done so.
First login
Your installation 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 administrator, you’ll be taken directly to the login page. Enter the administrator username and password. If the login is successful, a pop-up will display apps compatible 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.