Nextcloud doesn't think it can write to its directory

Details

Nextcloud version: N/A
Operating system and version : Ubuntu 18.04
Apache or nginx version : Caddy v2.1.1
PHP version : 7.2

Reproduction

Hi folks. I am completely baffled by this permissions error.

image

My server is caddy, running as user ‘caddy’ and serving from /srv/nextcloud. I’m not using SELinux.

# ls -laZ /srv/nextcloud
total 172
drwxr-xr-x 2 caddy caddy ?   4096 Aug  5 13:00 .
drwxr-xr-x 5 caddy caddy ?   4096 Aug  5 12:43 ..
-rw-r--r-- 1 caddy caddy ? 158285 Feb 20 14:31 setup-nextcloud.php
-rw-r--r-- 1 caddy caddy ?     34 Aug  5 12:55 whoami.php

# cat /srv/nextcloud/whoami.php
<?php echo get_current_user(); ?>

# curl http://nextcloud.mydomain.tld/whoami.php; echo
caddy

Clearly, the webserver can read and write to /srv/nextcloud:

# sudo -u caddy touch /srv/nextcloud.test.php

# sudo -u caddy echo "I can RW!" > /srv/nextcloud/test.php

# ls -l /srv/nextcloud
total 164
-rw-r--r-- 1 caddy caddy 158285 Feb 20 14:31 setup-nextcloud.php
-rw-r--r-- 1 caddy caddy     10 Aug  5 13:01 test.php
-rw-r--r-- 1 caddy caddy     34 Aug  5 12:55 whoami.php

# curl http://nextcloud.mydomain.tld/test.php
I can RW!

But I still get this error.

Can’t write to the current directory. Please fix this by giving the webserver user write access to the directory.

# curl -s http://nextcloud.mydomain.tld/setup-nextcloud.php?step=1 | grep "Dependencies"
                            <p class="warning" style="text-align:center; font-size:13px;">Dependencies not found.<br />Can't write to the current directory. Please fix this by giving the webserver user write access to the directory.<br/></p>

I’ve also tried manual installs , but they’ve all ended in some kind of “Operation not permitted” error.

Not sure if this is a NextCloud issue, a caddy issue, or an ubuntu issue. Hopefully someone can point me in the right direction.

ummm quick chime in… all nextcloud directories need to belong to your webuser. if caddy:caddy isn’t your webuser you’re in trouble.

plus: use of apache is recommended… nginx works. caddy? could be a problem itself.

am I allowed to ask: did you follow any howto set up a nextcloud server? or are you just trying to get it running all on yourself?

I’ve put this project on hold, but while debugging a wordpress site, I realized that the php-fpm user also needs access to the WP document root. The same might be true for NextCloud. Running chgrp on the server folder might fix it but I haven’t tried it yet. I will chime in when I get around to testing that.

1 Like

Hi,

I am getting the same error.

I am installing the Next Cloud on Oracle Linux 8.4

I installed PHP version 7.4.6

I placed the setup-nextcloud.php file in the /var/www/html folder.

The folder is owned by apache user and granted the access rights as 764

I tried writing the file using the following command as user apache and was successful.

sudo -u apache echo “I can RW!” > /srv/nextcloud/test.txt

I am still getting the error while running the setup-nextcloud.php as user does not have the permission.

Am I missing something in my installation?

I got the solution.

The error was on account of SELINUX.

I had to disable the SELINUX in settings file at /etc/selinux/config

Thereafter I could resume the installation process.

Regards.