Permission problem after moving data folder

Hi all,
i’m new to nextcloud and i’m not able to resolve this problem.
I installed nextcloud on a new vm running ubuntu server using the standard installation script.
After that i moved the data folder using the solution1 as explained in this topic: HowTo: Change / Move data directory after installation

Now i’m able to access the files in the new directory but i can’t delete or add new files.

the new data path is in /mnt/nextcloud and it is a samba share auto mounted at the server startp with cifs utils.

Also the command
sudo -u www-data php -f /var/www/html/nextcloud/console.php files:scan --all
report:

Permissions can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164

Errors in the nc log:

|Errore|PHP|Error: fopen(/mnt/nextcloud/data_dir_writability_test_627c1d214e4f6.tmp): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#580||2022-05-11T22:31:29+0200|
|Errore|PHP|Error: fopen(/mnt/nextcloud/data_dir_writability_test_627c1cc9aa4dc.tmp): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#580||2022-05-11T22:30:01+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:22+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:22+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:21+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:21+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:21+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:21+0200|
|Avviso|appstoreFetcher|OCP\Files\GenericFileException: file_put_contents failed||2022-05-11T22:29:20+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/appstore/apps.json): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:29:20+0200|
|Errore|PHP|Error: file_put_contents(/mnt/nextcloud/appdata_ocijspse9cqd/css/icons/icons-vars.css): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#296||2022-05-11T22:27:29+0200|

thanks

Did you try visiting this link it pointed you to?

https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions

You can also verify your permissions and ownership of the directories with ls -la
And change those permissions with chown and such

The link unfortunatly is not giving any useful information.

LS -LA Results:

/mnt/nextcloud (my new data folder):


 0 drwxr-xr-x 2 root root 0 May 11 21:13 appdata_ocijspse9cqd
 0 drwxr-xr-x 2 root root 0 May 11 21:00 files_external
14 -rwxr-xr-x 1 root root 0 May 11 20:58 index.html
 0 drwxr-xr-x 2 root root 0 May 11 21:13 nextcloud

/var/www/nextcloud

 4 drwxrwxrwx 43 www-data www-data  4096 May  2 16:34 3rdparty
 4 drwxrwxrwx 53 www-data www-data  4096 May 11 21:01 apps
20 -rwxrwxrwx  1 www-data www-data 19327 May  2 16:31 AUTHORS
 4 drwxrwxrwx  2 www-data www-data  4096 May 11 22:06 config
 4 -rwxrwxrwx  1 www-data www-data  3924 May  2 16:31 console.php
36 -rwxrwxrwx  1 www-data www-data 34520 May  2 16:31 COPYING
 4 drwxrwxrwx 22 www-data www-data  4096 May  2 16:34 core
 8 -rwxrwxrwx  1 www-data www-data  6260 May  2 16:31 cron.php
 4 drwxrwxrwx  2 www-data www-data  4096 May 11 20:58 data
12 drwxrwxrwx  2 www-data www-data 12288 May  2 16:31 dist
 4 -rwxrwxrwx  1 www-data www-data   156 May  2 16:31 index.html
 4 -rwxrwxrwx  1 www-data www-data  3456 May  2 16:31 index.php
 4 drwxrwxrwx  6 www-data www-data  4096 May  2 16:31 lib
 4 -rwxrwxrwx  1 www-data www-data   283 May  2 16:31 occ
 4 drwxrwxrwx  2 www-data www-data  4096 May  2 16:31 ocm-provider
 4 drwxrwxrwx  2 www-data www-data  4096 May  2 16:31 ocs
 4 drwxrwxrwx  2 www-data www-data  4096 May  2 16:31 ocs-provider
 4 -rwxrwxrwx  1 www-data www-data  3139 May  2 16:31 public.php
 8 -rwxrwxrwx  1 www-data www-data  5340 May  2 16:31 remote.php
 4 drwxrwxrwx  4 www-data www-data  4096 May  2 16:31 resources
 4 -rwxrwxrwx  1 www-data www-data    26 May  2 16:31 robots.txt
 4 -rwxrwxrwx  1 www-data www-data  2452 May  2 16:31 status.php
 4 drwxrwxrwx  3 www-data www-data  4096 May  2 16:31 themes
 4 drwxrwxrwx  2 www-data www-data  4096 May  2 16:32 updater
 4 -rwxrwxrwx  1 www-data www-data   383 May  2 16:34 version.php

Actually it is useful. Nextcloud normally is www-data and not root as far as I know for user or group permissions. :person_shrugging:

Your new data folder needs to be www-data as opposed to root

Was the problem resolved? Wenn yes, how?

For the data directory try to do

sudo chmod 770 /mnt/nextcloud

If that doesn’t work, try also

chown -R www-data:www-data /mnt/nextcloud

(Change /mnt/nextcloud to your path)

This topic has come up a zillion times here in the forum and was even answered in this thread.

The Nextcloud folder and data folder should be owned by the web server user. On Debian/Ubuntu based distributions this is usually the user www-data. Further it is recommended to set the permissions for folders to 750 and for files to 640.

chown -R www-data:www-data /path/to/nextcloud
find /path/to/nextcloud/ -type d -exec chmod 750 {} \;
find /path/to/nextcloud/ -type f -exec chmod 640 {} \;

Thanks for information
I have the same problem - but on a Proxmox-container.
Is the soluten the same for Proxmox?
I think, it’s different to use the accounts - in Proxmox uid ?

I don’t use LXC myself but I’d say yes.

I don’t think so, because Nextcloud and the web server ar not aware they are running in a container, so the Nextcloud folders and files, including the data folder and its contents, need to be owned by www-data, regardless from where and how the storage is mounted.