Default owner/group for Nextcloud directories and files?

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / ā€œas availableā€ basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):

    33.0.0

  • Operating system and version (e.g., Ubuntu 24.04):

    • Fedora 43 (virtual machine on Truenas25.10.2.1)
  • Web server and version (e.g, Apache 2.4.25):

    • Apache/2.4.66 (Fedora Linux)
  • Reverse proxy and version _(e.g. nginx 1.27.2)

    • nginx 1.28.2-1.fc43
  • PHP version (e.g, 8.3):

    • PHP 8.4.18
  • Is this the first time you’ve seen this error? (Yes / No):

    • N/A
  • When did this problem seem to first start?

    • Installation
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)

    • Installed thru Portainer running on Fedora VM.
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)

    • No

Summary of the issue you are facing: As a new user…

When attempting to run occ throws exception or complains ā€œCannot write into ā€˜config’ directory!ā€. The installation directories and files show the following ownerships:

root@docker:/var/nfsmounts/nextcloud# ls -lha
total 8.0K
drwxr-xr-x.  4 root    root      34 Mar  7 12:44 .
drwxr-xr-x.  6 root    root      82 Mar  4 23:03 ..
drwxr-xr-x. 15      33 tape    4.0K Mar  7 13:45 data
drwxr-xr-x.  6 unbound unbound 4.0K Mar  7 13:45 database

root@docker:/var/nfsmounts/nextcloud# ls -lhan
total 8.0K
drwxr-xr-x.  4   0   0   34 Mar  7 12:44 .
drwxr-xr-x.  6   0   0   82 Mar  4 23:03 ..
drwxr-xr-x. 15  33  33 4.0K Mar  7 13:45 data
drwxr-xr-x.  6 999 999 4.0K Mar  7 13:45 database

root@docker:/var/nfsmounts/nextcloud# less /etc/passwd | grep apache
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin

root@docker:/var/nfsmounts/nextcloud# sudo -u apache php /var/nfsmounts/nextcloud/data/occ config:system:set maintenance_window_start --value="1" --type=integer
Cannot write into "config" directory!
This can usually be fixed by giving the web server write access to the config directory.

But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.
See https://docs.nextcloud.com/server/33/go.php?to=admin-config
{"reqId":"643uNGVuIBioMswCnCmT","level":3,"time":"2026-03-07T23:26:29+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","scriptName":"/var/nfsmounts/nextcloud/data/occ","message":"fopen(/var/nfsmounts/nextcloud/data/config/config.php): Failed to open stream: Permission denied at /var/nfsmounts/nextcloud/data/lib/private/Config.php#210","userAgent":"--","version":"","occ_command":["/var/nfsmounts/nextcloud/data/occ","config:system:set"],"data":{"app":"PHP"}}

There is no UID 33 (tape) user on my system.

Some research suggests that these ownerships should be changed to apache:apache. All guides I have seen install on Ubuntu, on which I assume UIDs and GIDs differ from Fedora. So should I change ownership of the Nextcloud installation to Apache? I don’t want to break the installation, or force a re-install unless necessary. Nextcloud seems to work fine otherwise.

Hey @David_Allen,

The tape group showing up is just a cosmetic quirk — your Fedora host doesn’t have a local user with UID 33, so it falls back to whatever happens to be mapped to that UID in /etc/passwd. The Nextcloud container uses UID 33 for its internal www-data user (common across most container base images including Alpine), which is completely separate from your host’s Apache running as UID 48.

The real issue is that you’re trying to run occ using your host Apache (UID 48), but the files inside your Docker volume are owned by the container’s internal www-data user (UID 33). These are completely separate users as far as Linux is concerned.

Don’t run occ from the host at all — run it inside the container:

docker exec -u www-data <your-container-name> php occ config:system:set maintenance_window_start --value="1" --type=integer

You can find your container name with docker ps. If you’re using Portainer you can also see it there.

And definitely don’t chown the data directory to your host Apache — that would actually break things since the container wouldn’t be able to write its own files anymore.

If you want a handy alias so you don’t have to type the full exec command every time, something like this in your .bashrc works well:

alias occ='docker exec -u www-data <your-container-name> php occ'

Then you can just run occ <command> directly.

Sidenote: I’m assuming you’re using Docker here since you didn’t specify

h.t.h.


ernolf

1 Like

Thank you, that did the trick. I wish that was make clear in the documentation (which could be more complete and up to date).

In my early learning phase of using Nextcloud, I’ve found that little of the online info (via google, videos, etc.) can be directly applied to my own configuration:

Truenas –> Fedora VM –> Portainer –> Nextcloud (et. al.), …

so I’ve had to piece together bits and pieces to form a generalization of how to install, configure, and especially, fix the several warnings and errors which I feel really shouldn’t show up in the initial Nextcloud startup. Nevertheless, I think I have it working now, so thanks again for the help.

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