Nextcloud version (eg, 20.0.5):
Operating system and version (eg, Ubuntu 20.04):
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.4):
The issue you are facing:
Is this the first time you’ve seen this error? (Y/N): N
Steps to replicate it:
recently I updated to NC 27.02 and need to run OCC again.
My installation is on a shared hosting, and my SSH has no SU/SUDO command.
So all examples within the official Document for using OCC does not work for me.
To run OCC I used following methods in the past:
OCCWEB app (now obsolete)
Then as workaround for obsolete OCCWEB I used a second config file with following content (with data directory outside root):
<?php $CONFIG =['datadirectory' => realpath(__dir__ . '/../NC'),]; ?>
With this I could run OCC on a SSH session without any problems.
After several NC updates the 2. methods fails also.
- Someone found the solution using a PHP file in root directory (eg. runocc.php) and running it as webuser with HTTPS://yourcloud/runocc.php:
Missing indices after an update - #18 by NCUser68
<?php exec("/usr/local/php82/bin/php ./occ db:add-missing-indices 2>&1", $out, $result); echo "Returncode: " .$result ."<br>"; echo "Ausgabe des Scripts: " ."<br>"; echo "<pre>"; print_r($out); ?>
After Update to NC 26/27 the 3. method fails also.
So now following problem exist running OCC with SSH (“php occ --v”) returns following:
The output of your Nextcloud log in Admin > Logging:
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 web server write access to the root directory. See https://docs.nextcloud.com/server/27/go.php?to=admin-dir_permissions
The output of your config.php file in
/path/to/nextcloud (make sure you remove any identifiable information!):
<?php $CONFIG = array ( 'instanceid' => 'xx', 'passwordsalt' => 'xx', 'secret' => 'xx', 'trusted_domains' => array ( 0 => 'xx', 1 => 'xx', ), 'datadirectory' => '/var/www/vhosts/hostingXXXX.netcup.net/xx/xx/nextcloud/NC', #'datadirectory' => realpath(__dir__ . '/../NC'), 'dbtype' => 'mysql', 'version' => '188.8.131.52', 'overwrite.cli.url' => 'https://xx', 'dbname' => 'kxx_NC', 'dbhost' => '10.35.xx.xx', 'dbport' => '3306', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'xx', 'dbpassword' => 'xx', 'installed' => true, 'maintenance' => false, 'mail_smtpmode' => 'smtp', 'mail_smtpauthtype' => 'LOGIN', 'mail_sendmailmode' => 'smtp', 'mail_smtpauth' => 1, 'mail_smtphost' => 'xx', 'mail_from_address' => 'nc', 'mail_domain' => 'xx', 'mail_smtpport' => '587', 'mail_smtpname' => 'xx', 'mail_smtppassword' => 'xx', 'theme' => '', 'loglevel' => 2, 'updater.release.channel' => 'stable', 'has_rebuilt_cache' => true, 'default_phone_region' => 'DE', 'app_install_overwrite' => array ( 0 => 'occweb', ), 'updater.secret' => 'xxx', );
Meanwhile I moved my datadirectory within NC root directory (see above config content), but this did not solve the problem.
Here the access rigths of data directory (as I think here is the problem within my installation):
Base (750) , .htaccess (644), ocdata (754), nextcloud.log (640)
SUBDIR (755) → should this be 750 as well?
Files in SUBDIR (644)
What are the right access rigths for the above list? Does setting user rights solve my problem with OCC command?
----- UPDATE regarding method 3
After renaming (!?) the php script (access rights kept unchanged, 644) it run as webuser with success and updated the missing indices. But occ still does not work within a ssh session (see above)
-----UPDATE regarding SSH
when adding cache limit the hint to memory limit can be removed:
php -d memory_limit=512M ./occ --v
but the rest of above error message keep
Thank you in advance for any tip!