How to set permission for data folder

Hi,

I recently install NextCloud 17 on a VPS. My data folder is outside web root:

web root
/var/www/mysite/html

data folder
/var/www/mysite/data

I am unable to upload file as I keep getting error “An unknown error has occurred”. I believe it has something to do with data folder permission. I am logged in as sudo user and have applied the following permission:

sudo chown -R www-data:www-data /var/www/mysite/data
sudo find /var/www/mysite/data -type d -exec chmod 755 {} ;
sudo find /var/www/mysite/data -type f -exec chmod 644 {} ;

Now even via terminal (logged in as SSH) I am unable to access the folder. When I run following command I get “Permission denied” error:

cd /var/www/mysite/data

I am using nginx on Debian 9.

How to fix this permission issue?

Also you NC installation folder /var/www/mysite/html must have this permissions.

You should be able to check the permissions using sudo.
sudo ls -l /var/www/mysite/data

Is the data folder correctly set in your config file?

Both html and data folders have same permission and they are owned by www-data

Here’s result for data folder:

drwxr-xr-x 9 www-data www-data 4096 Dec 6 02:45 appdata_mlksbv8po6qs
drwxr-xr-x 2 www-data www-data 4096 Dec 6 02:41 files_external
-rw-r–r-- 1 www-data www-data 0 Dec 5 12:37 index.html
drwxr-xr-x 4 www-data www-data 4096 Dec 6 02:40 myadmin
-rw-r----- 1 www-data www-data 368049 Dec 6 03:04 nextcloud.log

Unclear description: I assume that you are not root when typing “cd …”:
check the permissions of /var/www/mysite/data and parents:
sudo ls -ld /var/www/mysite/data /var/www/mysite /var/www /var
If one of the parents have too few rights, no “cd” is possible.
Simple solution: be member of the group “ww-data” (entry in /etc/group)

When I login as root then I am able to go inside data folder. If I am logged in as other user and use sudo then I cannot access data folder and get permission denied error. Permission of data folder is given above which is owned by www-data

Make sure that the permissions fit in the parent directories as well!

1 Like

Does NextCloud save logs so I can check and see why I am unable to upload file?

EDIT

One more thing…this is IPv6 machine only…could this be the reason because may be NextCloud is referencing some script from IPv4 site?

Shouldn’t create a permission problem. I had problems with ipv6 only when using the app store (and perhaps the update check). I had to install NAT in the network to get ipv4 stuff.

I am using CloudFlare as reverse proxy. Could this be the cause of problem? Web server is nginx. Here’s log from browser console when I upload a file. Browser shows error 405 on the line PUT

jquery.js:8630 PUT https://somewebsite.com/index.php/apps/files/ 405
send @ jquery.js:8630
ajax @ jquery.js:8166
send @ jquery.fileupload.js?v=c351e1af-0:909
_onSend @ jquery.fileupload.js?v=c351e1af-0:971
(anonymous) @ jquery-ui.js:144
data.submit @ jquery.fileupload.js?v=c351e1af-0:677
(anonymous) @ file-upload.js?v=c351e1af-0:250
Promise.then (async)
submit @ file-upload.js?v=c351e1af-0:248
(anonymous) @ file-upload.js?v=c351e1af-0:567
Promise.then (async)
(anonymous) @ file-upload.js?v=c351e1af-0:566
.map..collect @ underscore.js:205
submitUploads @ file-upload.js?v=c351e1af-0:565
onNoConflicts @ file-upload.js?v=c351e1af-0:992
checkExistingFiles @ file-upload.js?v=c351e1af-0:777
add @ file-upload.js?v=c351e1af-0:1010
_trigger @ jquery-ui.js:697
(anonymous) @ jquery.fileupload.js?v=c351e1af-0:1040
each @ jquery.js:374
_onAdd @ jquery.fileupload.js?v=c351e1af-0:1033
(anonymous) @ jquery-ui.js:144
(anonymous) @ jquery.fileupload.js?v=c351e1af-0:1238
u @ jquery.js:3099
add @ jquery.js:3145
always @ jquery.js:3246
_onChange @ jquery.fileupload.js?v=c351e1af-0:1228
(anonymous) @ jquery-ui.js:144
a @ jquery-ui.js:606
dispatch @ jquery.js:4435
_.handle @ jquery.js:4121
App.vue:180 data.ocs.data is undefined or not an array
App.vue:180 data.ocs.data is undefined or not an array
App.vue:180 data.ocs.data is undefined or not an array

And here’s my nginx file

server
{
listen [::]:80;
root /var/www/mysite/html;
index portal.php index.php index.html index.htm;

server_name mysite.com;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param HTTPS on;
}
}