Correct folder and file permissions

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian
  • Web server and version (e.g, Apache 2.4.25):
    • Apache/2.4.62
  • PHP version (e.g, 8.3):
    • 8.2.25
  • Is this the first time you’ve seen this error? (Yes / No):
    • replace me
  • Are you using Cloudflare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

Everytime I use an occ command, the config.php is set to 640 and I get an error Writing to the "config" directory is not possible!. If I set the permission to 660 it works again. Now I am thinking something is totally wrong with my setup and hope someone can help me

  • Did someone experience this too?
  • Could someone tell me the correct file- and folder permissions?

Restic is using enable and disable maintenance mode and after the backup Nextcloud is not working anymore.
This is driving me nuts for three days now.

How you use occ command is it run as root or some user ?

as some user, specific the owner
sudo -u USER php occ:.xxxxx

The owner (and group) of all files and directories in the nextcloud directory should be the web server user, e.g. www-data on Debian/Ubuntu based systems, with permissions 0640 for files and 0750 for directories.

So in order for the occ commands to work they need to be executed as the web server user:

Examples:

sudo -u www-data php /path/to/nextcloud/occ maintenance:mode --on
sudo -u www-data php /path/to/nextcloud/occ maintenance:mode --off
2 Likes

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