Sorry, I'm not sure, if this is the correct forum because I don't know the cause for the issue, I'm facing.

I installed NextCloud on a Raspbian (Stretch 9) and moved the data directory to a mounted NFS folder. When I try to access NextCloud, I got the error message 'Data directory is not writable'.

So I dug a better deeper and could finally isolate the issue to the interaction between PHP7.0 and the NFS:

For some reason, the application can write to the directory but is_writable returns false.

I have created the following PHP script:

$dirname = '/var/churros/data/nextcloud/';
//$dirname = '/tmp/';

$myfile = fopen($dirname.'newfile.txt', "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
echo nl2br("File ".$dirname."newfile.txt written\n");

if (touch($dirname.'/chkpt.tmp')) {
   echo nl2br("touch(".$dirname."/chkpt.tmp) successful\n");
} else {
   echo nl2br("touch(".$dirname."/chkpt.tmp) failed\n");

if (is_writable($dirname)) {
        echo 'Directory '.$dirname.' is writable';
} else {
        echo 'Directory '.$dirname.' is not writable';


The result is that

When I change to directory to a local directory like \tmp everything is fine Screenshot of 'debug.php' with /tmp directory

My NFS is mounted as on /var/churros type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=,local_lock=none,addr=

and obviously the user mapping and access rights are correct:

namei -l /var/churros/web/nextcloud/
f: /var/churros/web/nextcloud/
drwxr-xr-x root     root     /
drwxr-xr-x root     root     var
drwxr-xr-x root     root     churros
drwxr-xr-x www-data www-data web
drwxrwxr-x www-data www-data nextcloud

Finally, on the command line, as user www-data, I can access the directory and write to it as well.

So: Any idea why PHP is_writable fails on the NFS directory?

  • PHP sometimes operates as nobody instead of the web server user (www, apache, www-data, etc). It's possible that could be causing he method to return false. Commented Jun 5, 2018 at 19:42
  • @JustinPearce - thanks, yeah that's what I thought as well but when I printed the user running PHP with $processUser = posix_getpwuid(posix_geteuid()); print $processUser['name'];, it shows www-data
    – allwi
    Commented Jun 6, 2018 at 20:27
  • PHP 7.0 no longer receives bug fixes. Update to PHP 7.1 (Nextcloud doesn't yet support 7.2). I also have Nextcloud storing data on an NFS server and have no issues. Commented Aug 17, 2018 at 12:28

1 Answer 1


In your code you state

$dirname = '/var/churros/data/nextcloud/';

However, when you demonstrate permissions below, you show

namei -l /var/churros/web/nextcloud/

How do we know that dir data is properly writable?

what is the result of:

namei -l /var/churros/data/nextcloud/


Also, I'm curious how

if (touch($dirname.'/chkpt.tmp')) {...

worked in the above script, it should have acted on /var/churros/data/nextcloud//chkpt.tmp (note double-slash between dir: nextcloud and filename chkpt.tmp).

I have occasionally included typos... and even typo'd scripts instead of copying/pasting exactly as is... My point is, at first glance it appears there are inconsistencies in the OP that are either contributing to the error while meeting certain conditions coincidentally, or very simply the first variable declaration needs to be modified to read .../web/nextcloud/ to meet the actual dir requirements as stated...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .