Data directory help requested

I’m having a really hard time getting the permissions straight. I’ve had nextcloud running, but had issues saving or deleting items. I’ve messed around with it more and currently can’t access the GUI.
Here’s the error I receive-
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.

nextcloud is installed on Ubuntu server. The data directory is an NFS share folder on a Synology NAS mounted at /mnt/storage. As root on the server I can write and delete files within /mnt/storage. I’ve given www-data rwx permissions on that folder. There is an .ocdata file at /mnt/storage.

You can check the permissions with:

sudo -u www-data touch /mnt/storage/test.txt

This should create an empty file as user www-data. For permissions, it’s not only the folder itself, the permissions of the parent folder and the mount options can be important as well.

1 Like

Thanks. I’m pretty new to Linux and knew there was a way to do that, but couldn’t remember how. When I first tried it said I didn’t have permission. I messed around with chmod and chown some more and now I’m able to add a file and have access to the GUI again.

Still am not able to delete a folder from the GUI though. As info, in DSM I have No mapping set for squash.

I think I finally have this all working.
For anyone else using similar setup with data folder on Synology NAS using NFS-
NSFv4 support is not checked
On the shared folder, no NAS local user has access
NFS permissions squash is set to no mapping

On the server, www-data was given ownership of the NFS mount.
chown -R www-data:www-data /mnt/storage
chmod -R 0770 /mnt/storage
#should result in- drwxrwx— 7 www-data www-data 4096 Sep 28 12:00 storage
#test ownership
sudo -u www-data touch /mnt/storage/test2.txt
#correct ownership of config.php at /var/www/nextcloud/config
chown root:www-data config.php
#should result in- -rw-rw---- 1 root www-data 697 Sep 15 01:40 config.php
#correct ownership permissions to delete
sudo php occ files:scan --all #older posts said to use sudo -u www-data php occ files:scan --all but that gave an error ‘Console has to be executed with the user that owns the file config/config.php’ root owns config.php so must be run as root.
#also had to update cron.php to run as root

Because people often ask about fstab, mine is- 10.10.0.73:/volume1/nextcloud /mnt/storage nfs defaults uid=www-data,gid=www-data,umask=770 0 0