NextCloud installed via "occ maintenance:install" -- but index.html/index.php tied to install

My stack for nextcloud is postgres, php-fpm, nginx on openBSD. I have used "occ maintenance:install to install nextcloud in /var/www/nextcloud with admin_user and admin_pass already specified.

When i connect to the webserver from browser – i feel the install script is getting triggered again. I get the error page with :


Error

    Your data directory is invalid.

    Ensure there is a file called ".ocdata" in the root of the data directory.

    Cannot create "data" directory.

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

I have doubled checked the permission for /var/www/nextcloud. The .ocdata is already present in the data/ directory. I don’t see any errors in php-fpm log or nginx logs. What could be amiss here.

Thanks.

This is a standard check that always runs because without access to the datadirectory Nextcloud can’t do much. :slight_smile:

I have doubled checked the permission for /var/www/nextcloud. The .ocdata is already present in the data/ directory.

The file ownership and permissions of /var/www/nextcloud (and everything under it; including your data/ directory under it) need to be owned by the same uid that FPM+nginx runs as.

I really do not see this as permission issue. Both php-fpm and nginx are running as www user which has read/write access to directories. I have double/triple checked that.

Its not about standard test. Its about installation script kickstarting but because the data directory is already present – the script fails. It assumes that their is permissions issue. I need to bypass the install process and directly go to admin page.

So your datadirectory is set to /var/www/nextcloud/data in your config/config.php, correct?

And the file /var/www/nextcloud/data/.ocdata exists you’re certain?

This particularly check is very simple. It just calls PHP’s file_exists() on the full path to .ocdata. There are only two things that can go wrong (well, for the most part…):

  • The data/ was moved without changing datadirectory in your config/config.php
  • Permissions of /var/www/nextcloud/data/.ocdata or any of it’s containing upstream folders is preventing the fpm user from accessing it

From the way you described running occ maintenance:install you only specified the admin user/pass, correct? (As long as you didn’t specify a custom data directory the default of INSTALLATION_FOLDER/data is used so /var/www/nextcloud/data in your case).

Its about installation script kickstarting but because the data directory is already present – the script fails. It assumes that their is permissions issue. I need to bypass the install process and directly go to admin page.

This isn’t an installation check. It’s a start-up check. It happens every time.

Thank you for pointing to the code from the error originates. Helps to get context. I think I had a mistake in my nginx.conf file. The root was pointing to /nextcloud. It should have been

root /nextcloud/data;

. After fixing this I don’t get the error message anymore. But I get a blank page. I was expecting the admin login page. Shouldn’t that be the case? Thank you once again for taking a looking

The root should point to the root of your installation, not your data directory. So that’s not the cause.

1 Like

You might try running this from the command line to see what it gets you:

php -r 'var_dump(file_exists("/var/www/nextcloud/.ocdata`));'

If that works, maybe try running it as your fpm user via sudo/su to confirm same results.

I did a complete reinstall and I am still facing the same issue. the query php -r ‘var_dump(file_exists(“/var/www/html/nextcloud/data/.ocdata”));’ returns bool(true).

I don’t see any error messages in php-fpm.log. Nothing in nginx error log. And no messages in nextcloud.log except:

{"reqId":"v7efYyZdcjsQQ1Yb5fMf","level":3,"time":"2024-06-17T14:39:52+00:00","remoteAddr":"","user":"postgres","app":"PHP","method":"","url":"--","message":"fopen(/var/www/html/nextcloud/config/config.php): Failed to open stream: No such file or directory at /var/www/html/nextcloud/lib/private/Config.php#225","userAgent":"--","version":"29.0.2.2","data":{"app":"PHP"}}```

which happens post initialization. 

Nginx is running under chroot. Could that be an issue with some internal paths?

It was the chroot issue. In the config/config.php changed to 'datadirectory' => '/html/nextcloud/data' and I am past this error. Happy to be on track. Thanks for helping out.

1 Like