How To Install NextCloud on Ubuntu 16.04

Install NextCloud on Ubuntu 16-04Preparation for installation NextCloud on Ubuntu 16.04

  • It is needed to have (virtual) machine with installed Ubuntu 16.04 minimal
  • Create users for ssh and add them to file  /etc/sudoers
  • Forbid login to ssh for root user in file /etc/ssh/sshd_config and restart the ssh sevice

Install NextCloud on Ubuntu 16.04

Install dependencies

Go to home directory

Go to NextCloud website and select latest archive to download

Install unzip package and extract the archive

Move unzipped folder to web folder

Apache configuration

Create config file for NextCloud

with following content

Make symbolic link for Apache

Enable needed modules

Restart the Apache

Correcting the permissions

It is needed to delegate permissions for   /var/www/nextcloud folder and its content. For this purpose there is NextCloud script. Create file

with following content

After file creating make it executable

Secure data directory

For security reason move NextCloud data folder beyond webserver directories

Setup MariaDB

Run and fill details

Create database

Connect to mysql and create database with user for it

Restart the Apache

First NextCloud launch

Open NextCloud web interface in browser

Input required setting details

Database details

NextCloud data folder: /nextcloud/data

Configuring OpCache

Setup OpCache

Add to the end of file following rows

Restart the Apache

Setup caching Memcached with Redis

Install memcached and redis

Restart the Apache

Edit redis config file  redis.conf

Find row

and replace it with

uncomment following rows

set unixsocketperm value to 770

Save file and add redis user to www-data group

Start redis service

Edit file  config.php

befor following row


Add redis to autorun

Restart the server to apply settings

Setup SSL

Create folder for key and certificate

Enter that folder

Generate certificate and key.

Note: you need to fill out Common Name with the valid server domain, name or IP address.

Edit file  default-ssl.conf

add right after the  SSLEngine on row

and change paths for key and certificate

Enable SSL for Apache

Restart the Apache

Note: browsers anyway will give warnings for insecure connection, because the certificate is self-signed.

Remove index.php from URL

Edit file  config.php



Go to the NextCloud root folder

and run the command

Restart the Apache

Check if URL works without index.php part by removing it and reloading the page

Setup logging for NextCloud

Edit file  config.php

add to the end of file before the closing bracket

Restart the Apache

Redirect requests from http to https

Open file  .htaccess

and add in the beginning of file following

Congratulations! Installation of NextCloud on Ubuntu 16.04 is finished.

p.s. NextCloud has ability to be installed from snap image, but some people tell that KVM virtualization is needed


Got error: