NC11: Migrated to another server, trouble with data directory

I moved my NC11 installation to another machine (both, old and new server is running Ubuntu 16.04 with nginx, MariaDB and php7) according to the migration-instructions in the manual.

I’m now at the point for the first start but get this error message in browser: Daten-Verzeichnis (/path/to/datadirectory) ist ungültig
Bitte stellen Sie sicher, dass das Datenverzeichnis auf seiner ersten Ebene eine Datei namens „.ocdata“ enthält.

This file “.ocdata” is there and the whole directory is owned by www-data user including write access.

I’m not sure if it’s important to mention: my installation was a owncloud-setup in the beginning and was migrated to NC9 on the old server.

How did you move the install?

from the original Server to a backup-place by rsync, from there to the new Server again by rsync (both, data and www directories).

I searched around the data directory for anything not normal and found that I have that directory on another physical disk in the system as the www, which was just a symlink to the mountpoint of the real disk. So I set the path to data directory in all config-files (php, nginx and NC) to the real path (/mnt/md0/nextcloud_data).

Now I get the maintenance-mode-message in browser, however when I try to disable maintenance mode by occ command, I get this response:

PHP Warning:  file_exists(): open_basedir restriction in effect. File(/mnt/md0/nextcloud_data/nextcloud.log) is not within the allowed path(s): (/var/www/:/tmp/:/etc/md0/nextcloud_data:) in /var/www/lib/private/Log/File.php on line 57
PHP Warning:  is_writable(): open_basedir restriction in effect. File(/mnt/md0/nextcloud_data) is not within the allowed path(s): (/var/www/:/tmp/:/etc/md0/nextcloud_data:) in /var/www/lib/private/Log/File.php on line 58
{"reqId":"N5LvDYNyzwGXwz1iDkUl","remoteAddr":"","app":"cli","message":"Memcache \\OC\\Memcache\\APCu not available for local cache","level":1,"time":"2018-01-04T04:20:13+00:00","method":"--","url":"--","user":"--","version":""}
{"reqId":"N5LvDYNyzwGXwz1iDkUl","remoteAddr":"","app":"cli","message":"Memcache \\OC\\Memcache\\APCu not available for distributed cache","level":1,"time":"2018-01-04T04:20:13+00:00","method":"--","url":"--","user":"--","version":""}
Nextcloud is in maintenance mode - no apps have been loaded
{"reqId":"N5LvDYNyzwGXwz1iDkUl","remoteAddr":"","app":"PHP","message":"file_exists(): open_basedir restriction in effect. File(\/mnt\/md0\/nextcloud_data\/.ocdata) is not within the allowed path(s): (\/var\/www\/:\/tmp\/:\/etc\/md0\/nextcloud_data:) at \/var\/www\/lib\/private\/legacy\/util.php#956","level":3,"time":"2018-01-04T04:20:13+00:00","method":"--","url":"--","user":"--","version":""}
{"reqId":"N5LvDYNyzwGXwz1iDkUl","remoteAddr":"","app":"PHP","message":"is_dir(): open_basedir restriction in effect. File(\/mnt\/md0\/nextcloud_data) is not within the allowed path(s): (\/var\/www\/:\/tmp\/:\/etc\/md0\/nextcloud_data:) at \/var\/www\/lib\/private\/legacy\/util.php#696","level":3,"time":"2018-01-04T04:20:13+00:00","method":"--","url":"--","user":"--","version":""}
Data directory (/mnt/md0/nextcloud_data) is invalid
Please check that the data directory contains a file ".ocdata" in its root.

Cannot create "data" directory (/mnt/md0/nextcloud_data)
This can usually be fixed by <a href="" target="_blank" rel="noreferrer">giving the webserver write access to the root directory</a>.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/lib/private/Console/Application.php:144
Stack trace:
#0 /var/www/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/occ(11): require_once('/var/www/consol...')
#2 {main}{"reqId":"N5LvDYNyzwGXwz1iDkUl","remoteAddr":"","app":"PHP","message":"chmod(): open_basedir restriction in effect. File(\/mnt\/md0\/nextcloud_data\/nextcloud.log) is not within the allowed path(s): (\/var\/www\/:\/tmp\/:\/etc\/md0\/nextcloud_data:) at \/var\/www\/lib\/private\/Log\/File.php#119","level":3,"time":"2018-01-04T04:20:13+00:00","method":"--","url":"--","user":"--","version":""}

So there’s several errors around path:

  1. no access to data directory. Which is not true. User www-data owns that directory with 750 permissions.
  2. It claims nextcloud.log is not within allowed path > not true too, that path is allowed in all config files
  3. It claims theres no .ocdata file in that directory > but it is

When you have a look at the error message, it’s right: /mnt/md0/nextcloud_data is not in the allowed directories /var/www/:/tmp/:/etc/md0/nextcloud_data. (/mnt/… vs /etc/…).
So, where ever you set the value of open_basedir (in the ini files FPM/CLI) of PHP, or in a vHost of nginx), you have to modify it, then the path should be found by your installation.

ok, I got it, the documentation did not say clear enough that NC/PHP/nginx must have access to the directory above the data-directory

It’s solved now. Thanks.

The error is back again. I started from beginning (migrating from old server to new machine) because nobody was able to find a way to troubleshoot the other problems with not working webinterface.

So I get this message:

both is not true, see:


$CONFIG = array (
  'instanceid' => 'instanceid',
  'passwordsalt' => 'passwordsalt',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => 'hostname',
    1 => '',
    2 => 'another.dyndns.domain',
    3 => '',
    4 => '',
    5 => '',
  'datadirectory' => '/srv/md0/nextcloud/data',
  'overwrite.cli.url' => '',
  'overwriteprotocol' => 'https',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloudDB',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'DBuser',
  'dbpassword' => 'DBpassword',
  'logtimezone' => 'UTC',
  'installed' => true,
  'maintenance' => true,
  'theme' => '',
  'loglevel' => 0,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  '' => false,

open_basedir contains /srv/md0/nextcloud in nginx-vhost-conf and php-fpm and php-cli’s php.ini files

nginx error log in empty

whole directory tree beginning from /srv/md0/nextcloud is owned by www-data:www-data

So there’s either another point where the data-directory is specified or this is an error somewhere in NC. I have no clue what else to check anymore.

because I’m out of ideas I just tried to replace the NC-www directory with a fresh one from NC with the same version as mine (11.0.3) and copied my config.php in there (same procedure us for an upgrade, however with the same version).

Now the error looks like this:

nginx-error-log is still empty

BTW: this error message asks for write-access to root for the webserver which can’t be serious for security concerns?

Don’t folders need the execution bit that you can look into them?

find /srv/md0/nextcloud -type d -exec chmod 750 {} \;

1 Like

yes, that’s right. Thanks for the successful hint.

I can remember, in previous versions of NC there have been detailed instructions how to set permissions. I found a thread here on the forums where folks complained why these instructions are missing now. Well, they would have been useful for me too. I’m not to lazy to follow instructions, but this detail that r+w access is not enough for a directory was not on my mind.