Your data directory is invalid

Nextcloud version (eg, 12.0.2): 15.0.2
Operating system and version (eg, Ubuntu 17.04): idk
Apache or nginx version (eg, Apache 2.4.25): Apache, version is hidden due to security reasons
PHP version (eg, 7.1): 7.3
PHP-Info is here:

The issue you are facing:

I try to index the files I uploaded via FTP using occ files:scan.

The whole thing is running on a netcup.de Webhosting Package.
I’m just beginning to learn about nextcloud and everything related to web services, so I thought a Vserver may be a little to difficult to start, I just wanted to set up a simple cloud.

The Webinterface is running so far, I got a few minor error messages, but that is may be due to the fact that its webhosting and not a didcated server:

There are some warnings regarding your setup.
The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.

No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.

The PHP OPcache module is not loaded. For better performance it is recommended to load it into your PHP installation.

Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running 'occ db:convert-filecache-bigint' those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read the documentation page about this.
filecache.mtime
filecache.storage_mtime

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install Nextcloud via ZIP with unpacking on the Server: same error
  2. Install nextcloud via Webinstaller: same error
  3. Install Nextclout with already unpacked Data and FTP-Upload: same error

The output of your Nextcloud log in Admin > Logging:

Warning	no app in context	Temporary directory /var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud/tmp is not present or writable

I did create a tmp folder just now, now no new log entries are occuring

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocnz2veaixpd',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'bbnext.de',
  ),
  'datadirectory' => '/var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '15.0.2.0',
  'overwrite.cli.url' => 'https://bbnext.de',
  'dbname' => 'k88852_nextcloud',
  'dbhost' => '10.35.47.182:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'k88852_xxxxxxx',
  'dbpassword' => 'xxxxxxx',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

nothing there maybe due to webhosting

Could the reason be that I access nextcloud using bbnext.de instead of hosting120128.a2fb5.netcup.net?

Thank you all for you help

Hi dschafar87,

by looking at your PHPInfo screenshot I guess you are using Debian 9 (Stretch).

Can you follow the path /var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud/data and see if that exists?

The error/info messages in your admin panel are mainly performance messages, which you can either change in your control panel from your hoster or contact your hoster to change them for you.

There is however one, which you should be able to fix yourself, if you have SSH access:

Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running 'occ db:convert-filecache-bigint' those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read the documentation page about this.
filecache.mtime
filecache.storage_mtime

Make a database backup and login via SSH afterwards, to execute the command:

occ db:convert-filecache-bigint

Hi CFelix,

I’m not able to follow that path:

bash: cd: /var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud/data: No such file or directory`

In my var directory there is only a tmp folder.
I created a PHP file with

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>

(saw that in another forum post), and the output is

/var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud.

So it seems the path is ok, I guess?

occ db:convert-filecache-bigint

This I can’t do, I get the same error messages:

bash-4.3$ php occ db:convert-filecache-bigint
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
The current PHP memory limit is below the recommended value of 512MB.
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/15/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /httpdocs/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /httpdocs/nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /httpdocs/nextcloud/occ(11): require_once('/httpdocs/nextc...')

Thanks for your help!

BR

Ben

Hi dschafar87,

I kind of thought that you would get the following error message:

bash: cd: /var/www/vhosts/hosting120128.a2fb5.netcup.net/httpdocs/nextcloud/data: No such file or directory

The data directory is needed to upload/store data in there. In your config.php the above path is set as datadirectory and will lead to error messages, if it doesn’t exist. Combined with the last error message:

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory.

It looks like there is a permission problem, preventing Nextcloud to create the data folder. Please check if the main folder (Nextcoud) has at least permission 775 (https://chmod-calculator.com). You can use chmod in the command line to change the permissions of folders and files.

As soon as you have the data folder, try going into it and execute the command pwd (Print work directory). This will show you the current path you are in as output. Copy that path and replace it with the one in your config.php -> datadirectory

As for the error message you get when executing the command:

occ db:convert-filecache-bigint

It looks like there is a php extension missing but I wouldn’t worry too much about it.

Hi CFelix,

thanks for the fast answer, you where right, my nextcloud only had 755 rights, changed it to 775, but with no effect. Is there something else I should do afterwards? Still getting the same error message.

Also, my data folder has 770 rights, so I guess that is correct.

What came back from the pwd command is as follows:

/httpdocs/nextcloud/data

Changed it like you recommended and got this when I try accessing the nextcloud webgui:

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.

And with another Post from the netcup-Forum I was able to resolve this:

There seems to be an issue with netcup and the path that nextcloud sees.
I’m to much of a n00b to really explain this correctly, but I put it here just in case someone with my limited knowledge stumbles upon the same issue.

So in the end the root of my problem really was Having the Nextcloud folder not with 0775 rights and the beforementioned pathway thing.

Thank you for your help, I really appreciate it!

BR

Ben

Ok, maybe I celebrated a little to early.
After successfully executing php occ files:scan --all last friday I tried the same today an got back the same old error:

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
The current PHP memory limit is below the recommended value of 512MB.
Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.

Cannot create “data” directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/15/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /httpdocs/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /httpdocs/nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /httpdocs/nextcloud/occ(11): require_once(’/httpdocs/nextc…’)

The config file I already checked, nothing changed besides the two factor authentitfication I installed last friday.

Any suggestions?

BR

Ben

EDIT: Nextcloud somehow did overwrite the config.php and the line

‘datadirectory’ => ((php_sapi_name() != ‘cli’) ? ‘/var/www/vhosts/hosting***.***.netcup.net’ : ‘’).’/httpdocs/data’,

was not in there anymore, instead there was the old static pathway…

1 Like

I am running nextcloud version 20 on a web hosting and encountered the same problem. The above solution workes only until an app is updated or an update is inserted for an app. Then the config files is overwritten, very annoying!

This solution works permanently:

  1. Create a new file in config/ folder: datadirectory.config.php
  2. Insert into file:
<?php

if (\OC::$CLI) {
	$CONFIG['datadirectory'] = '/path/cli';
} else {
	$CONFIG['datadirectory'] = '/path/web';
}

I use this solution also. But if I use this, cron not working anymore.
Do you have an Idea how I could form this If/else to exclude cron?

@Mannshoch That is weird, because with the solution I referenced above I don’t have a problem with cron. Is the problem with cron maybe because of something else or does it work without this additional config?