Setup NextCloud on Ubuntu 16.04 / Ubuntu 16.10 / Debian 8

Setup Nextcloud on Ubuntu 16.04
Setup NextCloud on Ubuntu 16.04

NextCloud is a web suite that provides a cloud storage over the network, 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.

System Requirements:

NextCloud works on top of LAMP,

Linux:  Ubuntu (14.04 & 16.04), Debian 7, SUSE Enterprise Server 11 SP3 & 12, Redhat Enterprise Linux / CentOS 6 and 7.

Apache 2 with mod_php

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

PHP 5.4+

NextCloud Enterprise is also available.


  • 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.


We will install the required packages for LAMP stack and the important PHP extension that NextCloud relies on.

### Ubuntu ###

sudo apt-get install -y apache2 mariadb-server libapache2-mod-php7.0 php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip php7.0-sqlite3

### Debian ###

sudo apt-get -y install wget mariadb-server php5-mysql php5 php5-gd php5-curl apache2 bzip2 php5-sqlite

Apache Modules (Must):

You need to enable the following modules in order 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 service apache2 restart

Download and Setup:

NextCloud offers you the zipped archives for server admin’s to download and manually set it up on top of LAMP.

cd /tmp/
tar -jxvf nextcloud-*.bz2
sudo mv nextcloud /var/www/html/
sudo mkdir /var/www/html/nextcloud/data

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

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

Create MySQL Database:

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

READ: Securing MariaDB

Make sure MariaDB server is running. Log into MariaDB server using the root user to create a database.

In Ubuntu 16.04 – You do not need to enter root password when you execute the mysql with sudo, simply press enter when mysql prompts for 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.


Setup NextCloud on Ubuntu 16.04 / Debian 8:

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


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

You can choose either SQLite or MySQL. If you chose to use 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.

Setup NextCloud on Ubuntu 16.04
Setup NextCloud on Ubuntu 16.04

Alternately you can also download the NextCloud clients to sync the documents across your devices.

Setup NextCloud on Ubuntu 16.04
Setup NextCloud on Ubuntu 16.04

On the home page of NextCloud. Clicking “+ sign” button and then Upload to begin uploading the files.

Setup Nextcloud on Ubuntu 16.04
Setup NextCloud on Ubuntu 16.04

That’s All!.


Share This Post