Installing and Configuring Nextcloud on Ubuntu Server

Nextcloud is a self-hosted open-source platform that lets you create your own personal cloud storage. Ditch the reliance on third-party services and gain complete control over your data with this feature-rich alternative. This guide will walk you through installing and configuring Nextcloud on an Ubuntu server using the convenient Snap package manager, and show you how to integrate your own domain name for seamless access.

Prerequisites:

  • An Ubuntu server with SSH access (DigitalOcean, Vultr, Linode are popular options)
  • A domain name and registrar account (Namecheap, Google Domains, etc.)
  • Basic understanding of terminal commands

1. Install Nextcloud Snap:

Open your terminal and update the package list:

sudo apt update && sudo apt upgrade

Next, install the Snap package manager if it’s not already present:

sudo apt install snapd

Finally, install the Nextcloud Snap package:

sudo snap install nextcloud

2. Configure Nextcloud Admin Account:

Once the installation finishes, run the following command to configure your Nextcloud admin account:

sudo nextcloud.manual-install username password

Replace username with your desired username and password with a strong password. This will set up the initial Nextcloud configuration and database.

3. Connect to Nextcloud Web Interface:

Open your web browser and navigate to your server’s IP address followed by :443 (e.g., https://your_server_ip:443). You should see the Nextcloud login screen. Use the username and password you created in step 2 to log in.

4. Integrate Your Domain Name:

To access Nextcloud using your own domain name, you need to configure a Virtual Host.

4.1. Create a Virtual Host File:

Open the Apache virtual host configuration file with root privileges:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Paste the following template, replacing your_domain_name with your actual domain name:

<VirtualHost *:443>
    ServerName your_domain_name

    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    <Location /wellcome>
        Allow From all
    </Location>

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/certs/your_domain_name/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/certs/your_domain_name/privkey.pem
</VirtualHost>

Replace /etc/letsencrypt/certs/your_domain_name/cert.pem and /etc/letsencrypt/certs/your_domain_name/privkey.pem with the actual paths to your SSL certificate and key files obtained from your Let’s Encrypt provider.

4.2. Enable the Virtual Host:

Enable the virtual host configuration file:

sudo a2ensite nextcloud.conf

4.3. Restart Apache:

Restart Apache for the changes to take effect:

sudo systemctl restart apache2

5. Update Trusted Domains:

Now, access your Nextcloud web interface using your domain name. You might see a warning about an untrusted domain. Go to Settings > Basic settings > Security & Privacy and add your domain name to the list of trusted domains.

6. Secure Your Nextcloud Installation:

For enhanced security, it’s crucial to secure your Nextcloud installation by:

  • Enabling two-factor authentication (2FA) for your admin account.
  • Installing and configuring security apps like fail2ban and Nextcloud Antivirus.
  • Keeping Nextcloud and its apps updated regularly.

Congratulations! You have successfully installed and configured Nextcloud on your Ubuntu server with Snap and integrated your own domain name for easy access. Now, explore the vast features of Nextcloud, manage your files, collaborate with others, and enjoy the freedom of your own personal cloud storage solution.