Nextcloud will not allow me to set /home/nextcloud/data/ as the data directory

When setting up Nexcloud 12 for the first time, I was unable to set the data directory to /home/nextcloud/data/ It said that the directory was inaccessible. I made sure that ownership was apache:apache and permissions were 775 throughout the /home/nextcloud directory.

I moved the data directory from the installed directory to home/nextcloud. after installation. I set the new location in config.php

I ran sudo -u apache ./occ files:scan --all

I got the following error:

Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/html/nextcloud/lib/private/Console/Application.php:145

There is an .ocdata file in that directory, but it is a 0 byte file.

[/details]

Nextcloud version 12.0.2
Operating system and version Centos 7.5.1804
Apache or nginx version Apache 2.4.6
PHP version (eg, 7.1): 7.0

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Y

Thanks, and let me know if additional info would be helpful.

Okay, I figured out what my problem was. I had allowed the /var/www/html/nextcloud/data/ folder in selinux, but not the /home/nextcoud/data/ folder. this was preventing that folder from being shared.

I needed to run the line:

semanage fcontext -a -t httpd_sys_rw_content_t ‘/home/nextcloud/data(/.*)?’

and then reload the rules.

1 Like