Rob's web

Nextcloud

Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices.

With the integrated OnlyOffice, Nextcloud application functionally is similar to Dropbox, Office 365 or Google Drive, but can be used on home-local computers or for off-premises file storage hosting.

The original ownCloud developer Frank Karlitschek forked ownCloud and created Nextcloud, which continues to be actively developed by Karlitschek and other members of the original ownCloud team.

Prerequisites

  1. Working webserver with vhosts
  2. Working SQL server
  3. Working SMTP server // Optional

Downloading

Download the latest sourcecode and sha256.

Installation

APCu

First we install the APCu memory cache:

# dnf install php-pecl-apcu
# cd /etc/php.d
# vi 40-apcu.ini
apc.enable_cli=1
# systemctl restart php-fpm httpd

Adjusting OPcache

# cd /etc/php.d/
# vi 10-opcache.ini
opcache.interned_strings_buffer=12
# systemctl restart php-fpm httpd

Creating the virtual host

Read the installation guide.

We need to create a virtualhost for our cloud.

# cd /srv/www/vhosts
# mkdir -p cloud.example.com/httpsdocs
# cd /srv/www/vhosts/cloud.example.com/httpsdocs/
# cp -R <path to nextcloud unzipped dir>/* .
# cd ..
# chown -R apache:apache
# cd httpsdocs/
# chcon -R -t httpd_sys_rw_content_t *

# cd /etc/httpd/conf/vhosts.d/
# cp vhosts.con cloud.example.com.conf
# vi cloud.example.com.conf	// Edit this file for your needs.

The vhosts.conf template is used and must be changed to your needs.

Also remove the first and second virtualhost.

<VirtualHost *:80>
        ServerName example.com
....
<VirtualHost *:443>
        ServerName example.com

We keep the third and fourth virualhost.

Start with replacing example.com to your domain.

Restarting the webserver

After you configure the server you need to restart the webserver.

# httpd -t
# systemctl restart httpd

Adding cloud to the DNS

You need to add cloud to your DNS example.com zone. Restart the DNS.

# cd /var/named/dynamic/
# vi example.com
.....
$TTL 10800      ; 3 hours
cloud            CNAME   server1
.....
server1                 A       192.168.1.11
                        AAAA    2a02:.....::1:1
.....
# systemctl restart named

Configuring

config.php

# cd /srv/www/vhosts/cloud.example.com/httpsdocs/config
# vi config.php		// Adjust to your needs.
.....
  'overwrite.cli.url' => 'https://cloud.example.com/',
  'overwritehost' => 'cloud.example.com/',
  'overwriteprotocol' => 'https',
.....
  'logo_url' => 'https://cloud.example.com/',
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'example.com',
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
  'mail_smtpsecure' => '',
  'mail_smtpauth' => false,
.....
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'redis_log_file' => '/var/log/redis/redis_nextcloud.log',
.....

TLS

You need TLS for this.

Use your wildcard certificates.

Setting up nextcloud

Background tasks

  1. Login with a administrator account.
  2. Click on the upper right logo and click on admin settings.
  3. On the left click on basic settings.
  4. Under background tasks use Cron.

We need to create a crontab job.

Email settings

Create an email-account for nextcloud.

Enter the SMTP settings. We have already set it in the config.php file.

Click on "Save" and "send mail" to test the settings.

Create crontab

Add to the apache crontab:

# crontab -u apache -e
*/5 * * * * sudo -u apache php /srv/www/vhosts/cloud.example.com/httpsdocs/cron.php

This run cron.php every 5 minutes.

Updating

If updating on-line doesn't work. Do it manual.

# cd /srv/www/vhosts/cloud.example.com/httpsdocs/updater
# sudo -u apache php updater.phar	// Follow the instructions.

To update the apps enter:

# cd /srv/www/vhosts/cloud.example.com/httpsdocs/
# sudo -u apache php occ app:update --all

Warnings

Nextcloud is strict with its files. You can't add files to the directory structure.

That also means you can't use lets-encrypt unless you have a wildcard certificate.

Links