"Data directory is invalid" when accessing with subdomain

Hey!

It’s my first time when I’ve setup NextCloud. I’m using version 11.0.2.7 on Synology DS212.
So far everything seems fine when accessing NextCloud from LAN (192.168.x.x/nextcloud). Also access from outside works as desired (domain/nextcloud or publicip/nextcloud).
But while I try to access cloud from a subdomain (ex. cloud.mydomain.com) which is binded directly to NextCloud directory, I’m getting and error “Data directory is invalid. Please check that the data directory contains a file “.ocdata” in its root”.

Got no idea at all what should I do about that.

Are you sure you aren’t running more than one instance of Nextcloud? Otherwise I’m not sure how changing the URL could affect the existence of the .ocdata file or the permissions. It sounds like it’s looking in a different location, meaning Nextcloud is running under a different configuration.

I’ve been messing around today. So far my config.php got:
‘datadirectory’ => ‘/volume1/nextcloud’,
‘overwrite.cli.url’ => ‘https://sub.mydomain.com’,
‘htaccess.RewriteBase’ => ‘/’,

.htaccess is set properly by occ

Also I’ve got setup in Apache24 (I have no idea how to post things with <> operators here):

<VirtualHost *:80 *:443>
ServerName sub.mydomain.com
SetEnv HOST sub.mydomain.com
DocumentRoot "/volume1/web/nextcloud"

DirectoryIndex index.html index.htm index.cgi index.php index.php5

<Directory “/volume1/web/nextcloud”>
Options MultiViews FollowSymLinks ExecCGI
AllowOverride All

Require all granted


…rest of file

Still got error about invalid data directory and insufficient rights to create ‘data’ directory.
When I change apache setup and config.php to access NextCloud through mydomain.com/nextcloud, everything works perfect.

I stopped getting error when I’ve set PHP’s open_basedir to “:/volume1/nextcloud” but it crashes (internal server error) as soon as I set strong permissions to the directories and files

{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“PHP”,“message”:“is_writeable(): open_basedir restriction in effect. File(/var/services/tmp) is n
ot within the allowed path(s): (/volume1/web/nextcloud::/volume1/nextcloud) at /volume1/web/nextcloud/lib/private/TempManager.php#259”,“level”:3,“time”:“20
17-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“no app in context”,“message”:“Temporary directory /var/services/tmp is not present or writable”,
“level”:2,“time”:“2017-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“PHP”,“message”:“is_writeable(): open_basedir restriction in effect. File(/var/services/tmp) is n
ot within the allowed path(s): (/volume1/web/nextcloud::/volume1/nextcloud) at /volume1/web/nextcloud/lib/private/TempManager.php#259”,“level”:3,“time”:“20
17-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“no app in context”,“message”:“Temporary directory /var/services/tmp is not present or writable”,
“level”:2,“time”:“2017-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“PHP”,“message”:“tempnam(): open_basedir restriction in effect. File(/var/services/tmp) is not within the allowed path(s): (/volume1/web/nextcloud::/volume1/nextcloud) at /volume1/web/nextcloud/lib/private/TempManager.php#241”,“level”:3,“time”:“2017-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“index”,“message”:“Exception: {“Exception”:“UnexpectedValueException”,“Message”:“Unable to detect system temporary directory”,“Code”:0,“Trace”:”#0 \/volume1\/web\/nextcloud\/lib\/private\/TempManager.php(56): OC\\TempManager->getTempBaseDir()\n#1 \/volume1\/web\/nextcloud\/lib\/private\/Server.php(507): OC\\TempManager->__construct(Object(OC\\Log), Object(OC\\AllConfig))\n#2 \/volume1\/web\/nextcloud\/3rdparty\/pimple\/pimple\/src\/Pimple\/Container.php(113): OC\\Server->OC\\{closure}(Object(OC\\Server))\n#3 \/volume1\/web\/nextcloud\/lib\/private\/AppFramework\/Utility\/SimpleContainer.php(115): Pimple\\Container->offsetGet(‘TempManager’)\n#4 \/volume1\/web\/nextcloud\/lib\/private\/ServerContainer.php(89): OC\\AppFramework\\Utility\\SimpleContainer->query(‘TempManager’)\n#5 \/volume1\/web\/nextcloud\/lib\/private\/Server.php(1284): OC\\ServerContainer->query(‘TempManager’)\n#6 \/volume1\/web\/nextcloud\/lib\/base.php(764): OC\\Server->getTempManager()\n#7 \/volume1\/web\/nextcloud\/lib\/base.php(1092): OC::init()\n#8 \/volume1\/web\/nextcloud\/index.php(38): require_once(’\/volume1\/web\/ne…’)\n#9 {main}",“File”:"\/volume1\/web\/nextcloud\/lib\/private\/TempManager.php",“Line”:246}",“level”:3,“time”:“2017-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}
{“reqId”:“Qgumwf3/fMfmUDlMiPvK”,“remoteAddr”:“192.168.1.1”,“app”:“PHP”,“message”:“PHP Startup: No such handler: DBA_DEFAULT at Unknown#0”,“level”:3,“time”:“2017-04-17T23:23:31+00:00”,“method”:“GET”,“url”:"/login",“user”:"–",“version”:“11.0.2.7”}

Okay, got it fixed by setting open_basedir to “:/dev/urandom:/var/services/tmp:/volume1/nextcloud”.
However I’m not sure if it’s right in terms of security or NextCloud itself.

Also Apache 2.4 on DSM 6 causes a lot of trouble. Installed old good Apache 2.2

Are you sure this is what you want in Apache? Shouldn’t that be /volume1/nextcloud?