Data Folder Error Message

Happy Sunday everyone,
on my server with Ubuntu 20.04.2 LTS, mariadb, apache and php 7.4, i installed NC 21.0.1.
Everything works perfectly, indeed perhaps it is faster than before, but this message appears in “Settings”“Summary”:

՚՚՚
There are errors related to your configuration.

 The cron job could not be run via the CLI. The following technical errors appeared :
    Your data directory is invalid Ensure there is a file called ".ocdata" in the root of the data directory.
    Your data directory is not writable Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/21/go.php?to=admin-dir_permissions.

՚՚՚

Where did I go wrong?
Thank you all.

1 Like

Under which user runs the Apache2 web server?
What is the exact path to the Nextcloud data directory which you’ve configured?

Make sure that the web server user is allowed to access the data directory and has write access to the directory, as written in the error messages!

1 Like

Thanks a lot for the answer!
I log in with the only user who is also an administrator.
Um how can I check that the web server user has write permissions? To the folders where I moved the data folder, I gave this command from the terminal:
sudo chown -R www-data: www-data /home/user/nextcloud/user/data/
sudo chmod -R 755 /home/user/nextcloud/user/data/
I was wrong?

Use “ps -ef| grep apache” to check under which user the web server is running.
The given commands are looking fine, except that it isn’t sufficient to grant access only for the users data directory. You have to make sure that the user is allowed to navigate to the whole path to the directory. The easiest way to do this is to switch to the web server user and navigate through the whole path, one directory after the other.

Are you really putting nextcloud’s data directory into some user’s home directory? That is usually going to be blocked by default configuration, both by standard permissions set on the user’s directory, AND by selinux, since the web server is not going to be permitted to access files in a user home context.

Also note that for a user to have permission to access a file, that user has to have read access not just to that specific file, but to EVERY directory in the heirarchy. /home/{user} is typically going to be chown {user}:{user} and chmod 700. And the selinux context will be something equivalent to unconfined_u:object_r:user_home_dir_t:s0 (that’s on Fedora, not ubuntu, so it could look a little different on yours.

Bottom line, try putting the data path back into a normal location for web data on your OS and set permissions accordingly.

1 Like

Good morning,
therefore, this is the result of the command ps -ef |grep apache:

՚՚՚
orestis@orestis:~$ ps -ef| grep apache
root 975 1 0 apr25 ? 00:00:06 /usr/sbin/apache2 -k start
www-data 47816 975 0 10:53 ? 00:01:39 /usr/sbin/apache2 -k start
www-data 48951 975 0 12:57 ? 00:01:04 /usr/sbin/apache2 -k start
www-data 49503 975 0 13:39 ? 00:00:22 /usr/sbin/apache2 -k start
www-data 49833 975 0 14:09 ? 00:00:23 /usr/sbin/apache2 -k start
www-data 49937 975 0 14:28 ? 00:00:03 /usr/sbin/apache2 -k start
www-data 50359 975 0 14:49 ? 00:00:02 /usr/sbin/apache2 -k start
www-data 50360 975 0 14:49 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 50361 975 0 14:49 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 50372 975 0 14:50 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 50468 975 0 14:55 ? 00:00:00 /usr/sbin/apache2 -k start
orestis 50943 50397 0 15:00 pts/0 00:00:00 grep --color=auto apache
՚՚՚

Mhmm wait, could you please explain this point to me better?

The strange thing is that everything works fine both in upload and download, even from Android apps …

Hey man, hope you are doing well…

Did you tried to create the “.ocdata” manually?

If you have not, try doing so:

sudo -u apache touch .ocdata

PS.: Remember to change “apache” to your apache’s user (like www-data or apache) and to be inside the right data directory.

Hope this helps, all the best mate.

See ya :smiley:

1 Like

Hi Beltran! :smiley:
The other weird thing is that the .ocdata file is already present in the Data folder… :thinking:

Depending on the given path /home/user/nextcloud/user/data/, you’ve placed the Nextcloud data directory in a users home directory, which is usually not the right place to store that data. because the access rights of “/home/user” are usually limited to the user himself and “www-data” isn’t allowed to access that directory.

Better is to store it in a directory like “/var/nextcloud/data” or “/data/nextcloud/data” and make sure that the www-data is allowed to accedd it or better is the owner of at least “/var/nextcloud/…”.

So I did as you advised me: I moved the data from / home / user, and in fact the situation has significantly improved:

՚՚՚
There are errors related to your configuration.

 The cron job could not be run via the CLI. The following technical errors appeared:
     The data folder is invalid Make sure there is an ".ocdata" file in the root of the data folder.

՚՚՚

The strange thing is that .ocdata is present in the folder … it has the size of 0 bite, but it is present …
However, the Nextcloud security scan gives me as a result “A” and that of SSL Server Test “A +”.

If a file couldn’t be found although it exists, it might be due to missing access rights. Check the ownership and access rights of the whole directory tree to the file and from the file itself to make sure it is accessible by the occ command.