How to fix data directory warning on Nextcloud

After installing Nextcloud, sometimes we got the following error on Admin page: “Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. It is strongly recommended that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.” Its not good because our valuable data can be accessed by unauthorized person. To fix this, please follow these steps.

Edit the Apache configuration file

Depends on your Apache settings, you may need to create a new configuration file for Nextcloud installation. In my case, I would create a configuration file called nextcloud.conf under /etc/apache2/sites-available directory.

nano /etc/apach2/sites-available/nextcloud.conf

Now paste these lines and make sure you change the directory to match with your installation directory

Alias /nextcloud "/var/www/html/nextcloud/"

<Directory /var/www/html/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/html/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud

</Directory>

Make sure AllowOverrideAll is there. Close and save the file.

Now create symlink of this nextcloud.conf to /etc/apache2/sites-enabled/nextcloud.conf

sudo ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf

Now we need to enable rewrite module:

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime

Finally restart apache web server

sudo systemctl restart apache2

Now the warning should be gone and you are good to go.

Consider to read the following tutorial prior to this post.

How to install Nextcloud on Debian 9

1 Comment

  1. TYPO in file location nano /etc/apach2/sites-available/nextcloud.conf MISSING e APACH2

    nano /etc/apache2/sites-available/nextcloud.conf

Leave a Reply