Difference between revisions of "Nextcloud"

From wiki
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
An opensource private cloud solution [https://nextcloud.com].
 
An opensource private cloud solution [https://nextcloud.com].
 +
 +
I'm running it on a synology diskstation, below is based on my experience.
 
=Installation=
 
=Installation=
  
Line 17: Line 19:
 
Change php settings:
 
Change php settings:
  
<code>
+
<syntaxhighlight lang=text>
 
upload_max_filesize = 16G
 
upload_max_filesize = 16G
 +
post_max_size = 16G
 +
</syntaxhighlight>
  
post_max_size = 16G
 
</code>
 
 
As my nextcloud server is a synology diskstation:
 
As my nextcloud server is a synology diskstation:
 +
<syntaxhighlight lang=text>
 +
vi /volume1/@appstore/PHP7.4/misc/php-fpm.ini
 +
/usr/syno/sbin/synoservice --restart pkgctl-PHP7.4
 +
</syntaxhighlight>
  
vi /volume1/@appstore/PHP7.2/misc/php-fpm.ini
+
;Change nginx setting for the nextcloud server
 +
:<code>client_max_body_size 0</code>
 +
:This will disable the checking of body size. The php settings rule.
  
/usr/syno/sbin/synoservice --restart <service>
+
==cronjob==
 +
;<code>*/5 * * * * sudo -u www-data php8.1 -f /var/www/nextcloud/cron.php</code>  
 +
:Configure this in your crontab or other job-scheduler
  
 +
==Client installation==
 +
<syntaxhighlight lang=bash>
 +
sudo add-apt-repository ppa:nextcloud-devs/client
 +
sudo apt update
 +
sudo apt install nextcloud-client
 +
</syntaxhighlight>
  
;Change nginx setting for the nextcloud server
+
==config file==
<code>client_max_body_size 0</code>
+
Located in the installation directory in ./config/config.php. Mine looks like:
:This will disable the checking of body size. The php settings rule.
+
<syntaxhighlight lang=php>
 +
<?php
 +
$CONFIG = array (
 +
  'maintenance' => false,
 +
  'instanceid' => 'REMOVED',
 +
  'passwordsalt' => 'REMOVED',
 +
  'secret' => 'REMOVED',
 +
  'trusted_domains' =>
 +
  array (
 +
    0 => 'nextcloud.local.antiperfect.org',
 +
  ),
 +
  'datadirectory' => '/volume1/nextcloud/',
 +
  'dbtype' => 'mysql',
 +
  'version' => '21.0.4.1',
 +
  'overwrite.cli.url' => 'https://nextcloud.<mydomain>',
 +
  'dbname' => 'nextcloud',
 +
  'dbhost' => 'localhost:/run/mysqld/mysqld10.sock',
 +
  'dbport' => '',
 +
  'dbtableprefix' => 'oc_',
 +
  'mysql.utf8mb4' => true,
 +
  'dbuser' => 'nextcloud',
 +
  'dbpassword' => 'REMOVED',
 +
  'installed' => true,
 +
  'mail_from_address' => 'nextcloud',
 +
  'mail_smtpmode' => 'smtp',
 +
  'mail_sendmailmode' => 'smtp',
 +
  'mail_domain' => 'mydomain.tld',
 +
  'mail_smtphost' => 'localhost',
 +
  'mail_smtpport' => '25',
 +
  'theme' => '',
 +
  'loglevel' => 2,
 +
);
 +
</syntaxhighlight>
 +
 
 +
==Force clients to use https==
 +
In the nginx frontend server configuration add:
 +
:<code>add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;</code>
 +
 
 +
==Enable imagick==
 +
In /var/packages/WebStation/target/misc/WebStation-php74/conf.d add:
 +
:<code>extension = imagick.so</code>;
 +
 
 +
==Enable caching==
 +
 
 +
* Running DSM7 and PHP8 edit <code>/usr/local/etc/php80/cli/conf.d/extension.ini</code>
 +
* Running DSM6 and PHP7 edit <code>/var/packages/WebStation/target/misc/WebStation-php74/conf.d</code>
 +
 
 +
add to this file:
 +
:<code>zend_extension = opcache.so</code>
 +
:<code>extension = apcu.so</code>
  
==cronjob==
+
In the nextcloud configuration file add:
;<code>*/5 * * * * sudo -u http php72 -f /var/www/nextcloud/cron.php</code>  
+
:<code>'memcache.local' => '\OC\Memcache\APCu',</code>
:Configure this
 
  
=Troubleshooting=
+
=Tips and Troubleshooting=
;sudo -u http php72 /var/www/nextcloud/occ files:scan --all
+
;<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan --all</nowiki>
 
:Rescan all files (update database)
 
:Rescan all files (update database)
 +
 +
;<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan --path="/<username>/files/<dir to scan>"</nowiki>
 +
:Rescan all files in specified path
 +
 +
;touch <file>
 +
:When everything looks OK, you fixed mounts and file permissions, try touch on the client.
 +
 +
;<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ db:convert-filecache-bigint</nowiki>
 +
:Needed after installing version 24.0.6
 +
 +
==Update music==
 +
<code>sudo -u www-data php8.1 /var/www/nextcloud/occ  music:scan hans --folder <relative to <user>/files> -vvv</code>
  
 
==A file is reported locked and it is not a file-protection issue==
 
==A file is reported locked and it is not a file-protection issue==
Line 48: Line 124:
 
# disable maintenance mode (undo first step).
 
# disable maintenance mode (undo first step).
 
::<code>'maintenance' => false,</code>
 
::<code>'maintenance' => false,</code>
 +
 +
==Upgrader times out==
 +
This is due to PHP timeout settings which may be increased.
 +
 +
The upgrade process progress is registered in <code>../nextcloud/updater-<whatever>/.step</code>. When a step is completed it shows e.g.: <code>{"state":"end","step":3}</code> for 'Create backup'. When the step that timed out is ready reload the updater pages and click the 'Continue Upgrade' button.
 +
 +
Repeat this a often as needed.
 +
 +
This issue can be prevented by running the whole process from the commandline
 +
sudo -u www-data php8.1 /var/www/nextcloud/updater/updater.phar
 +
 +
==Nextcloud remains in maintenance mode after upgrade==
 +
Turn off maintenance mode from the commandline and retry the upgrade from the command line.
 +
<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ maintenance:mode --off</nowiki>
 +
<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ upgrade</nowiki>
 +
 +
==Cronjob is running very long since a large number of files have been added==
 +
# Stop the cronjob schedule
 +
# Kill the running nextcloud cronjob(s) <code>ps -ef|grep nextcloud|grep cron</code>
 +
# <nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan-app-data</nowiki>
 +
 +
This solved the issue for me. More information may be available in the [https://github.com/nextcloud/server/issues/24401 related github issue].
 +
 +
==App cannot be installed from the web interface==
 +
Find the correct appname using occ list, then update
 +
<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ app:list</nowiki>
 +
<nowiki>sudo -u www-data php8.1 /var/www/nextcloud/occ app:update <appname></nowiki>
 +
 +
==After upgrade to version 25 directories are unavailable==
 +
The log-file has entry's ending like:
 +
<code>
 +
":"/volume1/web/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/volume1/web/nextcloud/remote.php","line":167,"args":["/volume1/web/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/volume1/web/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php","Line":355,"message":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin::OCA\\DAV\\Connector\\Sabre\\{closure}(): Return value must be of type ?int, float returned","exception":{},"CustomMessage":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin::OCA\\DAV\\Connector\\Sabre\\{closure}(): Return value must be of type ?int, float returned"}}
 +
</code>
 +
 +
This is because 32-bits support is dropped by a nextcloud component.
 +
 +
The solution is [https://help.nextcloud.com/t/cannot-access-files-after-upgrade-to-nextcloud-25/147823/6?u=michaing here]
 +
 +
Edit <code>/var/www/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php</code>.
 +
 +
In line 356 replace ?int by ?float
 +
 +
==The overview page complains about .well-known things not to be accessible==
 +
For webfinger I've not figured it out yet but I don't use that.
 +
 +
In the nginx frontend server configuration add:
 +
<syntaxhighlight lang=nginx>
 +
 +
  location ^~ /.well-known {
 +
 +
  location = /.well-known/carddav    { return 301 /remote.php/dav/; }
 +
  location = /.well-known/caldav      { return 301 /remote.php/dav/; }
 +
 +
  # Anything else is dynamically handled by Nextcloud
 +
  location ^~ /.well-known            { return 301 /index.php$uri; }
 +
 +
  try_files $uri $uri/ =404;
 +
  }
 +
 +
</syntaxhighlight>

Latest revision as of 23:21, 29 November 2023

An opensource private cloud solution [1].

I'm running it on a synology diskstation, below is based on my experience.

Installation

Installation is as simple as deploying a new web-site. Tips for installing on Synology bit outdated using php7

  • The package can be installed in the root of a (virtual) webserver.
  • The configuration is in <webroot>/config/config.php. To (re)start the initialization:
  1. (re)move the config file
  2. delete all tables in the nextcloud database
  3. put a file named CAN_INSTALL in the config directory.
  4. browse to your nextcloud webserver
  • When you have unix-sockets enabled use localhost:<socketpath> as dbhost

Allow larger files to be uploaded

Change php settings:

upload_max_filesize = 16G
post_max_size = 16G

As my nextcloud server is a synology diskstation:

vi /volume1/@appstore/PHP7.4/misc/php-fpm.ini
/usr/syno/sbin/synoservice --restart pkgctl-PHP7.4
Change nginx setting for the nextcloud server
client_max_body_size 0
This will disable the checking of body size. The php settings rule.

cronjob

*/5 * * * * sudo -u www-data php8.1 -f /var/www/nextcloud/cron.php
Configure this in your crontab or other job-scheduler

Client installation

sudo add-apt-repository ppa:nextcloud-devs/client
sudo apt update
sudo apt install nextcloud-client

config file

Located in the installation directory in ./config/config.php. Mine looks like:

 <?php
 $CONFIG = array (
   'maintenance' => false,
   'instanceid' => 'REMOVED',
   'passwordsalt' => 'REMOVED',
   'secret' => 'REMOVED',
   'trusted_domains' => 
   array (
     0 => 'nextcloud.local.antiperfect.org',
   ),
   'datadirectory' => '/volume1/nextcloud/',
   'dbtype' => 'mysql',
   'version' => '21.0.4.1',
   'overwrite.cli.url' => 'https://nextcloud.<mydomain>',
   'dbname' => 'nextcloud',
   'dbhost' => 'localhost:/run/mysqld/mysqld10.sock',
   'dbport' => '',
   'dbtableprefix' => 'oc_',
   'mysql.utf8mb4' => true,
   'dbuser' => 'nextcloud',
   'dbpassword' => 'REMOVED',
   'installed' => true,
   'mail_from_address' => 'nextcloud',
   'mail_smtpmode' => 'smtp',
   'mail_sendmailmode' => 'smtp',
   'mail_domain' => 'mydomain.tld',
   'mail_smtphost' => 'localhost',
   'mail_smtpport' => '25',
   'theme' => '',
   'loglevel' => 2,
 );

Force clients to use https

In the nginx frontend server configuration add:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

Enable imagick

In /var/packages/WebStation/target/misc/WebStation-php74/conf.d add:

extension = imagick.so;

Enable caching

  • Running DSM7 and PHP8 edit /usr/local/etc/php80/cli/conf.d/extension.ini
  • Running DSM6 and PHP7 edit /var/packages/WebStation/target/misc/WebStation-php74/conf.d

add to this file:

zend_extension = opcache.so
extension = apcu.so

In the nextcloud configuration file add:

'memcache.local' => '\OC\Memcache\APCu',

Tips and Troubleshooting

sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan --all
Rescan all files (update database)
sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan --path="/<username>/files/<dir to scan>"
Rescan all files in specified path
touch <file>
When everything looks OK, you fixed mounts and file permissions, try touch on the client.
sudo -u www-data php8.1 /var/www/nextcloud/occ db:convert-filecache-bigint
Needed after installing version 24.0.6

Update music

sudo -u www-data php8.1 /var/www/nextcloud/occ  music:scan hans --folder <relative to <user>/files> -vvv

A file is reported locked and it is not a file-protection issue

  1. put Nextcloud in maintenance mode: edit config/config.php and change this line:
'maintenance' => true,
  1. Empty table oc_file_locks (the default table prefix is oc_, this prefix can be different or even empty)
  2. disable maintenance mode (undo first step).
'maintenance' => false,

Upgrader times out

This is due to PHP timeout settings which may be increased.

The upgrade process progress is registered in ../nextcloud/updater-<whatever>/.step. When a step is completed it shows e.g.: {"state":"end","step":3} for 'Create backup'. When the step that timed out is ready reload the updater pages and click the 'Continue Upgrade' button.

Repeat this a often as needed.

This issue can be prevented by running the whole process from the commandline

sudo -u www-data php8.1 /var/www/nextcloud/updater/updater.phar

Nextcloud remains in maintenance mode after upgrade

Turn off maintenance mode from the commandline and retry the upgrade from the command line.

sudo -u www-data php8.1 /var/www/nextcloud/occ maintenance:mode --off
sudo -u www-data php8.1 /var/www/nextcloud/occ upgrade

Cronjob is running very long since a large number of files have been added

  1. Stop the cronjob schedule
  2. Kill the running nextcloud cronjob(s) ps -ef|grep nextcloud|grep cron
  3. sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan-app-data

This solved the issue for me. More information may be available in the related github issue.

App cannot be installed from the web interface

Find the correct appname using occ list, then update

sudo -u www-data php8.1 /var/www/nextcloud/occ app:list
sudo -u www-data php8.1 /var/www/nextcloud/occ app:update <appname>

After upgrade to version 25 directories are unavailable

The log-file has entry's ending like: ":"/volume1/web/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/volume1/web/nextcloud/remote.php","line":167,"args":["/volume1/web/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/volume1/web/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php","Line":355,"message":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin::OCA\\DAV\\Connector\\Sabre\\{closure}(): Return value must be of type ?int, float returned","exception":{},"CustomMessage":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin::OCA\\DAV\\Connector\\Sabre\\{closure}(): Return value must be of type ?int, float returned"}}

This is because 32-bits support is dropped by a nextcloud component.

The solution is here

Edit /var/www/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php.

In line 356 replace ?int by ?float

The overview page complains about .well-known things not to be accessible

For webfinger I've not figured it out yet but I don't use that.

In the nginx frontend server configuration add:

  location ^~ /.well-known {

   location = /.well-known/carddav     { return 301 /remote.php/dav/; }
   location = /.well-known/caldav      { return 301 /remote.php/dav/; }

   # Anything else is dynamically handled by Nextcloud
   location ^~ /.well-known            { return 301 /index.php$uri; }

   try_files $uri $uri/ =404;
  }