How to Install Nextcloud: A Step-by-Step Guide

Nextcloud is a powerful open-source software that allows you to create your own private cloud storage solution. With Nextcloud, you can securely store and access your files, calendars, contacts, and more from anywhere in the world. If you’re looking to take control of your data and privacy, installing Nextcloud on your own server is a great option.

Prerequisites

Before we get started with the installation process, there are a few things you’ll need:

  • A server with root access running a supported Linux distribution (such as Ubuntu, Debian, or CentOS)
  • At least 512MB of RAM (1GB recommended)
  • A domain name pointing to your server’s IP address
  • An SSL certificate for secure connections (optional, but recommended)

Step 1: Update System Packages

Before installing Nextcloud, it’s essential to update your server’s package repository to ensure you have the latest software packages. To do this, log in to your server via SSH and run the following commands:

sudo apt update

sudo apt upgrade

Step 2: Install Required Dependencies

Nextcloud requires a few dependencies to run correctly. Install these dependencies by running the following command:

sudo apt install apache2 mariadb-server libapache2-mod-php7.4 php7.4-gd php7.4-json php7.4-mysql php7.4-curl php7.4-mbstring

Step 3: Configure MariaDB

Nextcloud uses MariaDB as its database management system. To configure MariaDB, run the following command:

sudo mysql_secure_installation

Step 4: Create a Database for Nextcloud

Create a new MariaDB database and user for Nextcloud with the following commands:

sudo mysql -u root -p

CREATE DATABASE nextcloud;

CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

FLUSH PRIVILEGES;

EXIT;

Step 5: Download and Install Nextcloud

Download the latest version of Nextcloud from the official website and extract it in your web directory. Set the correct permissions by running the following command:

sudo chown -R www-data:www-data /var/www/html/nextcloud

Step 6: Set Up Apache Configuration

Create a new Apache configuration file for Nextcloud:

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

Add the following configuration to the file:

Alias /nextcloud "/var/www/html/nextcloud/"

Options +FollowSymlinks

AllowOverride All

Require all granted

CreateMode 0640

SetUIDGID www-data www-data

Step 7: Enable Apache Modules

Enable the required Apache modules for Nextcloud:

sudo a2enmod rewrite

sudo a2enmod headers

sudo a2enmod env

sudo a2enmod dir

sudo a2enmod mime

sudo a2enmod setenvif

sudo a2enmod ssl

sudo a2ensite nextcloud.conf

Step 8: Finish Installation via Web Browser

Finally, open your web browser and navigate to http://your_domain/nextcloud to complete the installation process. Follow the on-screen instructions to set up your Nextcloud instance with the database details you created earlier.

That’s it! You’ve successfully installed Nextcloud on your server. Enjoy secure and private cloud storage with Nextcloud!