How To Install Nextcloud On Debian 9

1
THIS DOCUMENT IS ALSO AVAILABLE FOR

Nextcloud is a web suite that provides cloud storage over the network, a fork of ownCloud. It is like a Google Drive / Dropbox that permits you to store and share your documents and pictures in a centralized location.

In this post, we will see how to install Nextcloud on Debian 9.

System Requirements

NextCloud works on top of LAMP,

Linux: Ubuntu 18.04, Debian 9 / 8, SUSE Enterprise Server 11 SP3 & 12, Redhat Enterprise Linux 7 / CentOS 7.

Apache 2.4 with mod_php

Database: MariaDB / MySQL, PostgreSQL, Oracle 11g.

PHP 7.1 and above.

Nextcloud Enterprise is also available.

Features

  • Access your files wherever you are.
  • Share your files with the other users and protect the public links with a password.
  • Two-factor authentication with QR Code and TOTP.
  • Monitor and Track change happening onto your file.
  • NextCloud can access files stored in external cloud storage service providers such as Amazon, Google, and Dropbox.

More here.

Prerequisites

Install Apache Web Server

sudo apt update 

sudo apt install -y apache2 bzip2

Install MariaDB

sudo apt install -y mariadb-server

Install PHP 7.2

Nextcloud doesn’t support PHP 7.0 which comes with Debian by default. Since Nextcloud requires PHP 7.1 and above, we will configure SURY repository to install PHP 7.2.

sudo apt install ca-certificates apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update

We will now install the PHP and its important extensions for NextCloud.

sudo apt install -y libapache2-mod-php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php-imagick php7.2-xml php7.2-zip php7.2-sqlite3

Enable Apache Modules

You need to enable the following modules to get NextCloud work properly.

sudo a2enmod rewrite

If you want, you can enable the below recommended Apache modules:

sudo a2enmod headers

sudo a2enmod dir

sudo a2enmod env

sudo a2enmod mime

Restart the Apache service.

sudo systemctl restart apache2

Install Nextcloud

Download Nextcloud

Nextcloud offers archive package for Linux server to download and manually set it up on top of the LAMP stack.

cd /tmp/

wget https://download.nextcloud.com/server/releases/latest.tar.bz2

tar -jxvf latest.tar.bz2

sudo mv nextcloud /var/www/html/

sudo mkdir /var/www/html/nextcloud/data

Update the ownership of the files inside the Nextcloud directory so that Apache user can write the data into it.

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

Create Database

If you are bringing up a MariaDB instance for the first time,

READ: Secure MariaDB with mysql_secure_installation command

Log into the MariaDB server using the root user to create a database.

You do not need to enter the root password when you execute the mysql with sudo, and simply press enter to get MariaDB shell when MariaDB prompts for the root password
sudo mysql -u root -p

Create a database called “nextclouddb“.

create database nextclouddb;

Grant “nextclouduser” to access the “nextclouddb” database on localhost with a password “password“.

grant all on nextclouddb.* to 'nextclouduser'@'localhost' identified by 'password';

Exit from the MariaDB prompt.

quit

Setup NextCloud

Open up your web browser and navigate it to below URL.

http://your-ip-addr-ess/nextcloud

Fill up the setup page with admin information (username and password) and then the location of the data folder.

You can choose either the SQLite or MySQL.

If you chose to use the SQLite database, then you do not have to enter database details. Using SQLite in a production environment is not recommended.

So, we will use MariaDB here. Enter the MariaDB database details in the below page.

Install Nextcloud on Debian 9 - Nextcloud Setup Page
Install Nextcloud on Debian 9 – Nextcloud Setup Page

Access Nextcloud

Click the close to close the Nextcloud popup.

Nextcloud Tour
Nextcloud Tour

You will now get the home page of Nextcloud. Click the “+ sign” button and then Upload to begin uploading the files.

Install Nextcloud on Debian 9 – Upload Files to Nextcloud
Install Nextcloud on Debian 9 – Upload Files to Nextcloud

Conclusion

I hope this post helped you to install Nextcloud on Debian 9. As a security measure, you can consider enabling HTTPS for Nextcloud.

You might also like