How to Install NextCloud on Ubuntu 22.04 with Snap?
Nextcloud is an open-source platform. It gives you complete control over your files, as you can manage your data and share files without any limitations. Most essentially, it is self-hosted.
It is super simple to install Nextcloud with Snap if you are using Ubuntu 22.04. Also, Snap Linux packages make the whole installation process smooth and quick. You need not worry about dependencies at all.
The installation of Nextcloud Snap also comes with everything you need. This includes PHP, MySQL, Redis, Apache2.4, mDNS, and the latest version of Nextcloud. All these components work together to ensure that your cloud storage runs efficiently and securely.
Before starting with the Nextcloud installation process, you need to ensure a few things. Below are the prerequisites.
Prerequisites
First, you will need to deploy and set up a fresh Ubuntu server on Cantech. Next, set up a subdomain A record to point to the server. You should also access your server console via SSH using a non-root user that has sudo privileges. And, of course, update your server to make sure everything is up-to-date.
Nextcloud Installation Process
Install Snap Daemon
=> Ubuntu server distributions have the Snap daemon pre-installed and active. However, in case it is not already installed, you can easily do so by running this command –
$ sudo apt install snapd
=> After the installation, you can verify the Snap version with –
$ sudo snap version
The output will appear; it may be similar to the below.
snap 2.57.1 snapd 2.57.1 series 16 ubuntu 22.04 kernel 5.15.0-41-generic
=> Snap is ready! Now, it is time to install Nextcloud. For that, run the following command –
$ sudo snap install nextcloud
=> You can check if Nextcloud is installed successfully by listing all installed snaps with:
$ sudo snap list
Configuration of Nextcloud
The files for Nextcloud are located in the /snap/nextcloud/current/htdocs/ directory. Its configuration file is stored in /var/snap/nextcloud/current.
So, you can make Nextcloud accessible on your domain name by adding the domain to the trusted domains array in the configuration file.
=> Start by configuring the Uncomplicated Firewall (UFW). This will allow HTTP traffic on port 80 –
$ sudo ufw allow 80/tcp
=> Then, allow HTTPS traffic on port 443:
$ sudo ufw allow 443/tcp
=> You can apply these changes by reloading the firewall.
$ sudo ufw reload
=> Now, open a web browser and go to your server IP (replace 192.0.2.1 with your actual server IP). This is to activate the database and configuration file values.
http://192.0.2.1
=> After that, you will be prompted to create an administrator account. You will need to enter a username and a strong password.
Click Install after entering the details. Installation is done!. You can now close the browser and return to the server console.
=> Next, you need to edit the Nextcloud configuration file, so open it using any text editor like Nano –
$ sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
=> Find the ‘trusted_domains’ => section in the file and replace the server IP with your domain name:
'trusted_domains' => array ( 0 => 'nextcloud.example.com', ),
=> Save the changes and close the file.
=> Also, secure your Nextcloud server with HTTPS. Install a Let’s Encrypt SSL certificate with the following command –
$ sudo nextcloud.enable-https lets-encrypt
=> You will see an output including the prompt explaining the requirements for getting the SSL certificate. It will ask you to confirm if you have met these requirements. Enter Y to accept them. After that, provide your email address and your domain name after you get the prompt.
The SSL certificate will be installed!
=> Next, restart Nextcloud to apply the changes.
=> Finally, use a web browser to visit your server’s domain.
https://nextcloud.example.com
Log in with the administrator username and password you set up earlier to access your Nextcloud dashboard.
The NextCloud installation on the Ubuntu 22.04 server using Snap is done!