Linux

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

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

after

add

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

Tried:

Got error:

4 thoughts on “How To Install NextCloud on Ubuntu 16.04

  1. I am following your step. Everything seems to be going okay. But when I enter “http:///nextcloud” the web browser says connection timed out! And I have entered my ip address correctly as well. I am using a digital ocean ubuntu droplet!

    Any help would be highly appreciated

    1. Use This for /etc/apache2/sites-available/nextcloud.conf

      Alias /nextcloud “/var/www/nextcloud/”

      Options +FollowSymlinks
      AllowOverride All
      Satisfy Any

      Dav off

      SetEnv HOME /var/www/nextcloud
      SetEnv HTTP_HOME /var/www/nextcloud

  2. Hi,
    Thank you !!
    First way I found that is actually working great for Nextcloud !
    But in : Remove index.php from URL
    I can’t access /var/www/nextcloud without doing :
    $sudo -s
    And when I ‘sudo -u www-data php occ maintenance:update:htaccess’, says :
    Error updating .htaccess file, not enough permissions?

    my user is in /etc/sudoers
    (add it through $sudo visudo)
    and did $usermod -aG sudo MY_USER too

    Any advice ?

Leave a Reply

Your email address will not be published. Required fields are marked *