Nextcloud

Nextcloud is an open source cloud solution written in PHP and distributed under the AGPLv3 license.

Nextcloud was initially released in 2016 as a fork of ownCloud and is maintained by Nextcloud GmbH.


Note

For this guide you should be familiar with the basic concepts of

Prerequisites

We’re using PHP in the stable version 7.4:

[isabell@stardust ~]$ uberspace tools version show php
Using 'PHP' version: '7.4'
[isabell@stardust ~]$

You’ll need your MySQL credentials. Get them with my_print_defaults:

[isabell@stardust ~]$ my_print_defaults client
--default-character-set=utf8mb4
--user=isabell
--password=MySuperSecretPassword
[isabell@stardust ~]$

If you want to use your cloud with your own domain you need to setup your domain first:

[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$

Installation

cd to your document root, then download the latest release of the Nextcloud and extract it:

Note

The link to the latest version can be found at Nextcloud’s download page.

[isabell@stardust ~]$ cd /var/www/virtual/$USER/html/
[isabell@stardust html]$ curl https://download.nextcloud.com/server/releases/latest.tar.bz2 | tar -xjf - --strip-components=1
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
 100 37.5M  100 37.5M    0     0  5274k      0  0:00:07  0:00:07 --:--:-- 6062k
[isabell@stardust html]$

Now point your browser to your uberspace URL and follow the instructions.

You will need to enter the following information:

  • Administrator username and password: Insert the credentials you want to use for the admin user

  • your MySQL hostname, username and password: the hostname is localhost and you should know your MySQL credentials by now. If you don’t, start reading again at the top.

  • your Nextcloud database name: we suggest you use an additional database. For example: isabell_nextcloud

Additionally, you can choose where Nextcloud is going to store your data files. It is recommended to place them outside of the webserver’s DocumentRoot, e.g. at /home/isabell/nextcloud_data/.

Configuration

Currently your Nextcloud installation is not capable of sending mail, e.g. for notifications or password resets. Log in with your admin user, go to settings > Administration > Basic settings and configure the email-server. Alternatively you can do this by editing the /var/www/virtual/$USER/html/config/config.php with your favorite editor. If yo want to keep things simple, use the sendmail option. If you prefer saving all messages in a (dedicated) mailbox use the smtp variant.

Sendmail Settings

and enter the following settings:

Warning

Make sure to replace the example values.

'mail_domain' => 'uber.space',
'mail_from_address' => 'isabell',
'mail_smtpmode' => 'sendmail',
'mail_sendmailmode' => 'pipe',

SMTP Settings

Note

In our example we assume that Nextcloud will use the user’s system mailbox user to send out mails. If you prefer to use an additional mailbox just adapt the settings. Refer to the manual if you don’t know your smtp password.

'mail_domain' => 'uber.space',
'mail_from_address' => 'isabell',
'mail_smtpmode' => 'smtp',
'mail_smtpport' => 587,
'mail_smtphost' => 'stardust.uberspace.de',
'mail_smtpsecure' => 'tls',
'mail_smtpauth' => true,
'mail_smtpauthtype' => 'LOGIN',
'mail_smtpname' => 'isabell@uber.space',
'mail_smtppassword' => 'MySSHPasswordIfUsingTheSystemMailbox',

Tuning

cronjob

For better performance, Nextcloud suggests to add a local cronjob.

Add the following cronjob to your crontab:

*/15  *  *  *  * php -f /var/www/virtual/$USER/html/cron.php > $HOME/logs/nextcloud-cron.log 2>&1

Memcaching

To further enhance performance, enable Memcaching.

To enable Memcaching (APCu), add the following line to your /var/www/virtual/$USER/html/config/config.php:

[...]
   'dbuser' => 'isabell',
   'dbpassword' => 'MySuperSecretPassword',
   'installed' => true,
   'memcache.local' => '\OC\Memcache\APCu',
 );

opcache

Enable opcache to further optimise performance.

To do that, create $HOME/etc/php.d/opcache.ini with the content:

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

PHP Memory

In order to increase the memory limit of php to the recommended value of 512 MB, create $HOME/etc/php.d/memory_limit.ini with the following content:

memory_limit = 512M

PHP Reload

After that you need to restart PHP configuration to load the last two changes:

[isabell@stardust ~]$ uberspace tools restart php
Your php configuration has been loaded.
[isabell@stardust ~]$

Database maintenance

To adapt some database configs to make Nextcloud run smoother execute these commands:

[isabell@stardust ~]$ cd html
[isabell@stardust html]$ php occ db:add-missing-indices
[isabell@stardust html]$ php occ db:convert-filecache-bigint

HSTS

Nextcloud will complain about your HSTS settings in the admin interface.

At the moment it is not possible to change the HSTS settings, as mentioned in the manual.

Onlyoffice (Community Edition)

To edit text and spreadsheet documents, you need to install and enable these apps from the admin interface:

  • Community Document Server (a light version of the Onlyoffice server)

  • Onlyoffice (the connector to the Onlyoffice server)

Both apps can be installed optional during the main install, but the huge document server may fail. Then install it manually from the shell:

[isabell@stardust html]$ cd apps
[isabell@stardust apps]$ curl -L https://github.com/nextcloud/documentserver_community/releases/latest/download/documentserver_community.tar.gz | tar -xvzf -

Reload the admin panel and enable the Community Document Server. A click on a text/spreadsheet document should now start the Onlyoffice Editor.

Nextcloud Talk

To can enable video/audio calls in your instance, install and enable the “Talk” app in the admin interface. If the web installation fails, install the app manually in your shell:

[isabell@stardust html]$ cd apps
[isabell@stardust apps]$ curl -L https://github.com/nextcloud/spreed/releases/download/v8.0.7/spreed-8.0.7.tar.gz | tar -xvzf -

Reload the page and press the talk icon in the top menu bar.

Updates

The easiest way to update Nextcloud is to use the web updater provided in the admin section of the Web Interface.

If you have installed Nextcloud on a subdomain it can happen that the update fails: Access to the UI is not possible and HTTP 403 errors are thrown. In most cases this happens due to wrong SELinux labels which can be fixed with finishing the update via console and setting the labels according the loaded SELinux policy.

[isabell@stardust ~]$ cd /var/www/virtual/$USER/html
[isabell@stardust html]$ php occ upgrade
[isabell@stardust html]$ restorecon -R .
[isabell@stardust html]$ php occ maintenance:mode --off
[isabell@stardust html]$

Note

Check the changelog regularly to stay informed about new updates and releases.


Tested with Nextcloud 18.0.2, Uberspace 7.4.3.0

Written by: Andreas Matschl | SpaceCode <andreas@spacecode.it>