Not able use occ commands no permission

Nextcloud version (eg, 20.0.5): 28.0.2
Operating system and version (eg, Ubuntu 20.04): 22.04
PHP version (eg, 7.4): 8.1

The issue you are facing:

I tried to using a occ command in the directory of nextcloud. I got this error and now I don’t know what to do:

The output from the console nextcloud/:

PHP Warning:  require_once(/root/nextcloud/nextcloud/console.php): Failed to open stream: Permission denied in /root/nextcloud/nextcloud/occ on line 11
PHP Fatal error:  Uncaught Error: Failed opening required '/root/nextcloud/nextcloud/console.php' (include_path='.:/usr/share/php') in /root/nextcloud/nextcloud/occ:11
Stack trace:
#0 {main}
  thrown in /root/nextcloud/nextcloud/occ on line 11

Do you really have installed Nextcloud in /root/nextcloud?
What occ command did you execute?

1 Like

I installed it in /root/nextcloud/nextcloud with docker-compose. Thats why I tried the command in this directory.

Hmmm - maybe you might run into truble, because the /root folder only has permissions to user “root”.

I am not sure, whether it is a general requirement:
Nextcloud requires permissions to user www-data, so it in normal cases will be installed f.e. in /var/www/nextcloud

btw.: You only did answer my 1st question.

I used the command to activate the maintenace mode.

Please post exactly the whole command, you tried to execute.

sudo -u www-data php occ maintenance:mode --on

That’s part of your problem. If you’re using Docker, the command must be ran in the container not on your host.

Please see the documentation: GitHub - nextcloud/docker: ⛴ Docker image of Nextcloud

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.