Nextcloud

From Segfault
Jump to: navigation, search

Installation

While Owncloud does provide packages for various distributions[1], Nextcloud only links to 3rd party provides, offering builds of their latest releases.[2]

When installing from the official release:

wget https://download.nextcloud.com/server/releases/nextcloud-12.0.5.tar.bz2{,.sha256,.asc}

gpg --recv-keys D75899B9A724937A
gpg --verify nextcloud*.bz2.asc
sha256sum -c nextcloud*.tar.bz2.sha256

cd $DOCROOT
tar -xjf nextcloud*.tar.bz2

The webserver needs to be able to write to certain parts of the installation, but not all:

sudo chown -cR root:root nextcloud/
sudo chown -cR www-data:www-data nextcloud/{.htaccess,.user.ini,3rdparty,apps,config,data}

Install some dependencies:

apt-get install php-apcu php-bz2 php-curl php-gd php-imagick php-intl php-json php-mbstring php-mcrypt php-mysql php-xml php-xml-parser php-zip

Enable PHP Opcache:[3]

$ cat /etc/php/7.0/mods-available/opcache.ini
zend_extension=opcache.so
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

Prepare the database:

> CREATE USER nextcloud@localhost IDENTIFIED BY 's3cr3t';
> CREATE DATABASE IF NOT EXISTS nextcloud;
> GRANT ALL PRIVILEGES ON nextcloud.* TO nextcloud@localhost;

With all that in place, the installer should start once a web browser is pointed to the document root.

The (newly generated) config/config.php can be adjusted to switch to pretty URLs[4]

 [...]
 'datadirectory' => '/var/www/nextcloud/data',
 'overwrite.cli.url' => 'https://www.example.net/nextcloud',
 'htaccess.RewriteBase' => '/nextcloud',

Re-generate $DOCROOT/.htaccess:

sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess

When serving Nextcloud in a subdirectory, we may also need the following settings on the web server to allow proper service discovery[5]

Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav

Update

The built-in updater appears to work just fine. We have to make some preparations first:

DOCROOT=/var/www                                                                          # Adjust as needed!
chown -R www-data:www-data $DOCROOT/nextcloud/

Start the web updater and let it run until:

Keep maintenance mode active?
[x] Maintenance mode will kept active.
Now trigger the migration via command line: ./occ upgrade

And we'll do just that:

sudo -u www-data php $DOCROOT/nextcloud/occ upgrade

If all went well, disable the maintenance mode:

sudo -u www-data php $DOCROOT/nextcloud/occ maintenance:mode --off

Adjust ownerships again:

sudo chown  -R root:root $DOCROOT/nextcloud/
sudo chown -cR www-data:www-data $DOCROOT/nextcloud/{.htaccess,.user.ini,3rdparty,apps,config,data}

Links

References