Still having issues getting NextCloud installed - "Can’t create or write into the data directory opt/nextcloud/data”

I still can’t get past the Initial Setup/Configuration page for NextCloud. Now it keeps giving me a “Can’t create or write into the data directory opt/nextcloud/data” Error message.

At least I’m making progress.

The nextcloud/data/nextcloud.log gives me the following three messages:
“Could not detect any host in http:///data/htaccesstest.txt”
“mkdir(): No such file or directory at /var/www/html/nextcloud/lib/private/Setup.php#312”
“Could not find resource js/setup.js to load”

I’ve checked the php.ini file for “open_basedir = none”. It wasn’t there, I added it. It made no difference.
I’ve checked my mySQL nextcloud database oc_storages table for correctly pointing at /opt/nextcloud/data
/opt/nextcloud and /opt/nextcloud/data belong to www-data user and group with 755 permissions (777 permissions made no difference… and 755 permissions mirror the default NextCloud install).

Any suggestions where to look next?

Installation is NextCloud on Ubuntu 20.04 Server (Headless) using NGINX, PHP 7.4, MariaDB, SSH, as subdomain.domain.dom (site works, until NextCloud installed… then it fails to configure/setup).

Okay… Like I said… I’m making progress.

I just re-checked NGINX error log and see the following:

open() “/var/www/html/nextcloud/data/htaccesstest.txt” failed (2: No such file or directory), client: 192.168.1.1, server: subdomain.domain.dom, request: “GET /data/htaccesstest.txt HTTP/1.1”

Shouldn’t it be trying to get this file from /opt/nextcloud/data ?
Where do I change this?

There is no “htaccesstest.txt” file in either /var/www/html/nextcloud/data/ or /opt/nextcloud/data/

I can create files as user “www-data” in both directories (“sudo -u www-data touch test.txt” works fine).

Yep… still learning.

I think the problem exists in my nginx configuration for subdomain.domain.dom

# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
    # The following 6 rules are borrowed from `.htaccess`

    rewrite ^/\.well-known/host-meta\.json  /public.php?service=host-meta-json  last;
    rewrite ^/\.well-known/host-meta        /public.php?service=host-meta       last;
    rewrite ^/\.well-known/webfinger        /public.php?service=webfinger       last;
    rewrite ^/\.well-known/nodeinfo         /public.php?service=nodeinfo        last;

    location = /.well-known/carddav     { return 301 /remote.php/dav/; }
    location = /.well-known/caldav      { return 301 /remote.php/dav/; }

    try_files $uri $uri/ =404;
}

After doing some more reading (research)… I think that perhaps NGINX isn’t being allowed permission… or more specifically, isn’t being instructed to write into the /opt/nextcloud/data/ directory.

But I’m not sure how to add that.

Am I correct, or missing the mark here… and if someone can guide my config, until I have a better understanding of how to code that specific allowance, I would greatly appreciate it. Thanks!

Or is it the PHP that isn’t being allowed / instructed to write into /opt/nextcloud/data/ ??

The PHP configurations have me completely confused.