Hello Future Nextcloud users,
Its now May 2, 2020 and I had this exact issue these weeks while trying to get nextcloud (version 18) up and running It seemed unsolvable at first but I managed to fix the issue finally after a few long hours of logfiles munching, some google-foo, and good input
from the helpdesk of my hosting provider.
I used the Softaculous auto-installer on the webserver where I rent some space to install NextCloud, however if you install(ed) it manually, just take the data and ignore the Softaculous bit. After installation, when login failed, I got te same error about the realpath open_basedir restriction and invalid path etc. (at a location which the installer had chosen to create all by itself, by the way). For the benefit of future users of NextCloud (and also OwnCloud I believe) here is how I fixed it:
-----------------------------------------------------------------------------------------------------------------------------------
1)
when installing the plugin via Softaculous, in the first lines you fill in the protocol (http/https) and the domainname, and then make sure to fill in a non-existing directory name in the third field. The installer will create it during install, but if you leave it empty, or if you use an existing folder, it can cause problems.
2)
For the second line, give a datadirectory name or leave it default (“nextclouddata”). The installer will then create the datadirectory automagically in a location that is not accessible from the internet: “home/_username_/nextclouddata/” (where _username_ is of course your own base account (root) name). And that location is the cause of the open_basedir problem. But we will fix that in a moment.
3)
Lastly, take note of the database name nextcloud wants to use, you will need it later.
.
After the installation Softaculous will report that everyting went well, but if you try to login and get that (by now well known) error message about the realpath open_basedir being at the wrong/illegal location, then you can try this fix:
-> create a directory called “include” in the domains folder (where your sites are also located), like so: ". . . home/_username_/domains/include/ ".
-> now move the nextcloud datafolder to that directory:
". . . home/_username_/domains/include/nextclouddata/ ".
-> Update the new location in two places: first in the nextcloud config file, but equally important: in the database.
You can find the config file usually located at: "…/public_html/nextcloud/config/config.php"
(or replace “nextcloud” with the name of your install folder). In that PHP config file (on line 10) add the new foldernames to the address line:
’datadirectory’ => '/home/_username_/domains/include/nextclouddata/'
-> and last but not least: open phpMyAdmin (or whatever tool you use for database maintenance), locate the nextcloud database (you remembered the db name, right?) , then locate the table called “oc_storage”. There are two entries in that table. In the first entry, in the first field of the first column (called “id”) change the content from: “local:: /home/_username_/nextclouddata” to include the new folders:
“local::/home/_username_/domains/include/nextclouddata/”
Execute the SQL query to update it, and that’s basically it: you’re done
You can now navigate your webbrowser to the admin login page (typically http;//domainname,com/nextcloud/index.php) and login with the admin credentials that you filled in when you installed the plugin. Upon logging in, nextcloud will check the config file and the database oc_storage table, it will find the (new) datadir location and check if the directory and it’s contents are there (which they are), it will also check if it can write into that directory (which it can) , and it will think everything is just peachy and it will let you in.
Note1: If you do not use Softaculous, then you are probably well versed in these matters and you can adopt/implement the above information in other ways, fitting your modus operandi.
Note2: *Don’t forget to check if Nextcloud still has write permissions on that datafolder that was moved, and check the owner of the folder. If you download the datafolder, delete the original and re-upload the datafolder to the new location, you now are the new owner of the folder, but my knowledge isn’t good enough to actually comment on this… *
-----------------------------------------------------------------------------------------------------------------------------------
The above worked for me.
However, I can not guarantee it will work for you: there are so many different webserver setups (I think mine is Apache on a Linux box but I’m not even sure) so maybe in your case it might not work, or folder names and locations might be all different. But despite that, you should have enough info to tackle the problem specified to your situation. I’ve spent so much time today hunting down this error and it’s solution that I think it would be good to drop this info here – hopefully it can be of use for future nextcloud/owncloud users that encounter this issue.
-> PS, Yes, I think owncloud has the same bug, and the same solution might work there too, but no guarantees of course :~)
Have a nice day !
Hans.