NextCloud with an Amazon S3 bucket as primary storage

TL;DR

You need to reinstall from scratch, migrating to S3 (or any other object storage) after installation isn’t supported.

https://github.com/nextcloud/server/issues/5865#issuecomment-341698048

You also have to configure the S3 settings before installation and dedicate the entire bucket to NextCloud.

Full details

The instructions I used to get my installation working are below but they were cribbed from;

https://github.com/nextcloud/server/issues/5865#issuecomment-332827521

Basically once you’ve extracted the installation from the tar file, you must add the S3 configuration before running the installation script.

Create a file storage.config.php in the config folder, I used a file similar to the one below.

<?php

$CONFIG = [
  'objectstore_multibucket' => [
    'class' => 'OC\\Files\\ObjectStore\\S3',
    'arguments' => [
      'bucket' => 'abc',
      'key' => '<AWS S3 Key>',
      'secret' => '<AWS S3 Secret>',
      'use_ssl' => true,
      'region' => '<AWS region>'
      'use_path_style' => false,
    ],
  ],
];

Run the installation script in Nextcloud via the web or CLI based installer.

The instance will now use the object storage as primary storage if all the connection details are correct.

NextCloud PHP errors

After updating NextCloud to 10.0.2 I was getting a ton of errors in my log files and the NextCloud desktop client wouldn’t sync;

[Tue Dec 27 15:47:11.548182 2016] [proxy_fcgi:error] [pid 20114] [client <IP address>:58648] Invalid status line from script ‘<filename>.jpg': 0

I had this with 10.0.1 but I just ignored it and reverted to 10.0.0 as I didn’t have time to look in to it.

With the Christmas break I was able to and 5 minutes later I found this;
https://help.nextcloud.com/t/unable-to-access-directories-starting-with-a-hash-sign/6308/4

The issue appears to be down to the way that PHP-FPM was being accessed by Apache.

I was using something similar to;

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:$port/var/www/owncloud/\

Changing it to the following enabled NextCloud to work fine (again)

<FilesMatch \.php$>
  SetHandler "proxy:fcgi://127.0.0.1:$port"
</FilesMatch>

I’m assuming something changed in the code which impacted the above as none PHP files are accessed through a PHP script but I’m just glad its working again.