How to Install and Configure Nextcloud Hub 21 on Ubuntu 20.04 LTS

//

John Smith

Nextcloud Hub 21 is a powerful self-hosted collaboration platform that offers file sharing, video conferencing, calendar management, and more. This guide provides a comprehensive walkthrough for installing and configuring Nextcloud Hub 21 on an Ubuntu 20.04 LTS server, ensuring optimal performance and security. (Installation on Linux – Nextcloud Documentation)


🧰 Prerequisites

Before proceeding, ensure the following:

  • A fresh installation of Ubuntu 20.04 LTS.
  • A non-root user with sudo privileges.
  • A static IP address assigned to your server.
  • A domain name pointed to your server’s IP (optional but recommended).

đŸ“Ļ Step 1: Update System Packages

Begin by updating your system’s package index and upgrading existing packages:

sudo apt update && sudo apt upgrade -y

🔐 Step 2: Install and Configure OpenSSH

Install OpenSSH to enable remote access: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

sudo apt install openssh-server -y

Verify the SSH service status: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

sudo systemctl status ssh

Allow SSH through the firewall:

sudo ufw allow ssh

🌐 Step 3: Install Apache Web Server

Install Apache: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

sudo apt install apache2 -y

Enable Apache to start on boot and verify its status: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

sudo systemctl enable apache2
sudo systemctl status apache2

🐘 Step 4: Install and Configure MariaDB

Install MariaDB server: (Install Nextcloud on Ubuntu 24.04 LTS – YouTube)

sudo apt install mariadb-server -y

Secure the MariaDB installation: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

sudo mysql_secure_installation

During the prompt: (Configure Ubuntu Server 20.04 to Host NextCloud Hub 21)

Log into MariaDB to create a database and user for Nextcloud: (Install Nextcloud on Ubuntu 24.04 LTS – YouTube)

sudo mysql -u root -p

Inside the MariaDB shell:

CREATE DATABASE nextcloud;
CREATE USER 'nc_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace 'strong_password' with a secure password.


🐘 Step 5: Install PHP and Required Extensions

Install PHP and necessary extensions: (Basic NextCloud install instructions for newbie, step by step – Reddit)

sudo apt install php libapache2-mod-php php-mysql php-gd php-json php-curl php-mbstring php-intl php-imagick php-xml php-zip php-bcmath php-gmp -y

Verify PHP version:

php -v

Ensure it’s compatible with Nextcloud Hub 21.


đŸ“Ĩ Step 6: Download and Extract Nextcloud

Navigate to the web root directory and download Nextcloud: (Download and install Nextcloud)

cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/nextcloud-21.0.0.zip

Install unzip if not already installed:

sudo apt install unzip -y

Extract the Nextcloud archive:

sudo unzip nextcloud-21.0.0.zip

Set appropriate ownership and permissions: (Installation of NextCloud 21 – â„šī¸ Support)

sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud

âš™ī¸ Step 7: Configure Apache for Nextcloud

Create a new Apache configuration file for Nextcloud:

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

Add the following configuration:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/nextcloud/
    ServerName your_domain.com

    <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off
        </IfModule>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>

Enable the new site and necessary Apache modules:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2

Install Certbot:

sudo apt install certbot python3-certbot-apache -y

Obtain and install an SSL certificate:

sudo certbot --apache -d your_domain.com

Follow the prompts to complete the SSL setup.


đŸ› ī¸ Step 9: Complete Nextcloud Installation via Web Interface

Open your web browser and navigate to http://your_domain.com or https://your_domain.com if SSL is configured.

Follow the on-screen instructions:

  • Create an admin account.
  • Enter the database details:
    • Database user: nc_user
    • Database password: strong_password
    • Database name: nextcloud
    • Database host: localhost
  • Choose the data folder location (default is fine).

Click “Finish setup” to complete the installation.


🔄 Step 10: Configure Background Jobs

For optimal performance, configure Nextcloud to use cron for background jobs. (Installation and server configuration – Nextcloud Documentation)

Edit the crontab for the web server user:

sudo crontab -u www-data -e

Add the following line:

*/5 * * * * php -f /var/www/nextcloud/cron.php

This schedules the cron job to run every 5 minutes.


🧰 Additional Configuration and Security Hardening

  • Enable Caching: Install and configure Redis for improved performance. sudo apt install redis-server php-redis -y sudo systemctl enable redis-server sudo systemctl start redis-server

Add the following to Nextcloud’s config.php: (Installation of NextCloud 21 – â„šī¸ Support)

'memcache.local' => '\OC\Memcache\Redis',
'redis' => [
    'host' => 'localhost',
    'port' => 6379,
],
  • Set Up Fail2Ban: Protect against brute-force attacks. sudo apt install fail2ban -y

Configure as needed.

  • Regular Backups: Implement a backup strategy for your data and database.

đŸ“ē Video Tutorial

For a visual walkthrough, refer to the following video:

(How to Install Nextcloud Hub 21 on Ubuntu 20.04)



Leave a Comment