howto:nextcloud

Nextcloud

Information applies to: NethServer 7.x, Nextcloud 24.x (for previous versions check old revisions of this document)

Nextcloud provides a safe, secure, and compliant file synchronization and sharing solution on servers that you control. NethServer 7 provides a preconfigured Nextcloud instance integrated with other NethServer services.

Note: With the release of Nextcloud 18.0.1, nextcloud rpm was merged into nethserver-nextcloud
Note: With the release of Nextcloud 18.0.4 we switched from PHP 7.2 to PHP 7.3
Note: With the release of Nextcloud 21.0.2 we switched from default mariadb-5.5 database server to rh-mariadb105
Note: With the release of Nextcloud 24.0.5 we switched from PHP 7.3 to PHP 8.0


Where is Nextcloud installation located?

  • The rpm package puts Nextcloud files under /usr/share/nextcloud directory.
  • Nextcloud config file is located at /usr/share/nextcloud/config/config.php.
  • User data is under /var/lib/nethserver/nextcloud directory.


Can I upgrade Nextcloud via its built-in updater?
It is not recommended. NethServer manages updates through RPM packages.

How can I run Nextcloud'socc command?
occ command should be run as the HTTP user (apache) and with the same php version used by your Nextcloud instance. One method to call occ command is:

sudo -u apache scl enable php80 -- php -dmemory_limit=1024M -d apc.enable_cli=1 /usr/share/nextcloud/occ

An easier way is to make use of the occ wrapper (/usr/local/sbin/occ) provided by NethServer:

occ


After updating/upgrading Nextcloud, the apps are disabled
Nextcloud update/upgrade procedure disables 3rd. party apps to avoid incompatibility problems. Server logs keep track of which apps were disabled. After a successful update/upgrade procedure you can use the Applications page to update and re-enable the apps. Apps can also be enabled from the command line:

# example: enabling calendar app
occ app:enable calendar


Logged in as admin but don't have access to administration features
At first install, NethServer's Nextcloud instance has an internal admin account with a default password of Nethesis,1234 (that should be changed). When an account provider is installed (nethserver-directory: openLDAP; nethserver-dc: Active Directory) users can authenticate into Nextcloud with their LDAP credentials. This can pose some inconvenience, as the account provider might have an account named admin as well, and trip you when login in to Nextcloud. This can be alleviated by setting a different password for Nextcloud's admin account.


When accessing to Nextcloud's URL, the apache httpd web server can return the following error message when any of the related services Nextcloud relies on is not working:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Check the status of mysqld/mariadb and PHP services:

systemctl -l status php80-php-fpm rh-mariadb105-mariadb@nextcloud.service


occ user:resetpassword admin


occ maintenance:mode --off


This could be due to a partial upgrade done by the rpm packages. The specific issue might have been reflected on server logs. By running occ upgrade command you'll either finish the upgrade process or get some errors showing the problem:

occ upgrade


Some files have not passed the integrity check. These could be custom files, or leftovers from a previous update or installation.

  • Find the problematic files using the “List of invalid files…” shown on Nextcloud's admin interface
  • Determine the type of issue (INVALID_HASH, MISSING_FILE, EXTRA_FILE, EXCEPTION…) for each file
  • Act accordingly to the self-explanatory issue type and the solutions provided in the Nextcloud documentation
  • Trigger a “Rescan…” to verify the issues have been solved


If cron is the selected job scheduler for Nextcloud, make sure a cron job for /usr/share/nextcloud/cron.php is in place, and it is called by apache user using the right php version. Since Nextcloud 14.0.3 release, NethServer takes care of this.


Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add “default_phone_region” with the respective ISO 3166-1 code of the region to your config file.

This advice is not important. If you want to, you can follow as advised, editing `/usr/share/nextcloud/config/config.php` file to add your country's “default_phone_region”. Here's an example for Italy:

  'default_phone_region' => 'IT',

or even easier, you can add that information to the config file by making use of occ command:

  occ config:system:set default_phone_region --value="IT"


The database is missing some optional columns. Due to the fact that adding columns on big tables could take some time they were not added automatically when they can be optional. By running “occ db:add-missing-columns” those missing columns could be added manually while the instance keeps running. Once the columns are added some features might improve responsiveness or usability.

Fix it as instructed by the warning message:

  occ db:add-missing-columns


The database is missing some primary keys. Due to the fact that adding primary keys on big tables could take some time they were not added automatically. By running “occ db:add-missing-primary-keys” those missing primary keys could be added manually while the instance keeps running.

Fix it as instructed by the warning message:

  occ db:add-missing-primary-keys


Nextcloud implements a file locking mechanism to avoid file corruption. By default, Nextcloud uses the database locking backend.

Under some circumstances, a file could remain inaccessible due to an unreleased lock. To manually release the locks:

  occ maintenance:mode --on
  
  /opt/rh/rh-mariadb105/root/bin/mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" nextcloud
  
  DELETE FROM oc_file_locks WHERE 1;
  \q
  
  occ maintenance:mode --off

If it does not work, a user reported that a temporary workaround was to disable file locking (`'filelocking.enabled' ⇒ false,`) from the config.php file. Consult Nextcloud's documentation.


Please, avoid using the built-in updater. Stick to the update methods supported by your GNU/Linux distribution. If you need a newer version ask to the package maintainer.


To revert the changes:

  mysqldump --socket /run/rh-mariadb105-mariadb/nextcloud-mysql.sock --databases nextcloud --default-character-set=utf8mb4 -r nextcloud-$(date +%F-%T).sql  # optional
  cp -aR /usr/share/nextcloud /usr/share/nextcloud.bad  # optional (as a backup)


Restore Nextcloud's config.php file form a backup. If no backup present, edit Nextcloud's config file (e.g. /usr/share/nextcloud/config/config.php) removing the lines referring to maintenance and updater.secret.

  yum reinstall nethserver-nextcloud


Check Nextcloud is working as expected. If all is good you can get rid of the backup files:

  rm nextcloud-*.sql
  rm -r /usr/share/nextcloud.bad/    # use -rf to force removal without confirmation


Problem arises if some major release update was skipped. Nextcloud manual says:

It is best to keep your Nextcloud server upgraded regularly, and to install all point releases and major releases. Major releases are 11, 12, 13 and so on. Point releases are intermediate releases for each major release. For example, 13.0.4 and 12.0.9 are point releases. Skipping major releases is not supported.

Some users reported the following solutions (having a backup of Nextcloud's files, configuration and user data is advisable before proceeding; examples are unrelated between them and therefore can refer to older or different Nextcloud versions):

1. Find out the previously installed major release (checking logs, yum history or using any other method, like the one that follows). As the thrown exception means Nextcloud upgrade failed, the config file still contains a reference of the old Nextcloud version (this version is changed by the installer on a successful upgrade):

[root@server ~]# grep "'version'" /usr/share/nextcloud/config/config.php

Let's say we find out that the version installed before the upgrade attempt was 21.0.3

2. Find out installed and available Nextcloud packages:

[root@server ~]# yum --showduplicates list *nextcloud
(...)
Installed Packages
nethserver-nextcloud.noarch          1.19.2-1.ns7           @nethserver-updates
Available Packages
(...)
nethserver-nextcloud.noarch          1.17.1-1.ns7           nethserver-updates 
nethserver-nextcloud.noarch          1.18.0-1.ns7           nethserver-updates 
nethserver-nextcloud.noarch          1.19.0-1.ns7           nethserver-updates 
nethserver-nextcloud.noarch          1.19.1-1.ns7           nethserver-updates 
nethserver-nextcloud.noarch          1.19.2-1.ns7           nethserver-updates 
(...)

Version numbering between Nextcloud official release and NethServer's Nextcloud release differ. You can correlate them by looking at nethserver-nextcloud changelog:

[root@server ~]# rpm -q --changelog nethserver-nextcloud

From the gathered information we know that:

  1. before the failed upgrade we had Nextcloud 21.0.3 (that is nethserver-nextcloud-1.17.1-1.ns7)
  2. currently we have (a non-working) nethserver-nextcloud-1.19.2-1.ns7 (that is Nextcloud 23.0.1)
  3. we skipped a major Nextcloud release (we had Nextcloud 21 and upgraded to Nextcloud 23, skipping Nextcloud 22)

3. Downgrade nethserver-nextcloud packages to the latest next major release that follows to the previously installed release (for instance, if the previously installed major release was Nextcloud 21 the next major release that follows is Nextcloud 22):

[root@server ~]# yum downgrade nethserver-nextcloud-1.19.1-1.ns7   # downgrading to Nextcloud 22.2.3

4. Keep updating nethserver-nextcloud packages to the latest next major release until reaching the current release (if there is any other major release in-between, do the update specifying the packages' version):

[root@server ~]# yum update nethserver-nextcloud


b) Migration scripts to latest version (experimental procedure):
Get installed version:

occ --version

Enable debug mode:

vi /usr/share/nextcloud/config/config.php
  'debug' => true,

Get migration status:

occ migrations:status core

Migrate Nextcloud to latest version (migration scripts):

occ migrations:migrate core

Edit Nextcloud's config.php file replacing the old version number with the current (installed) Nextcloud version number. Also remember to disable debug mode by removing the debug line previously added:

vi /usr/share/nextcloud/config/config.php
 'version' => '23.0.1',

Upgrade Nextcloud and disable maintenance mode:

occ upgrade
occ maintenance:mode --off

Check Nextcloud's config.php file to make sure the upgrade set the current (and correct) version.


  • OnlyOffice Community Document Server (built-in support through Nextcloud apps, since Nextcloud 18)
  • Bookmarks app
    • If Bookmarks app fails to install due to gmp library not being available, install the library for the php version being used:
yum install rh-php73-php-gmp
systemctl reload rh-php73-php-fpm


  • howto/nextcloud.txt
  • Last modified: 2022/10/24 20:41
  • by Marc