Nextcloud webroot and data directory - best practices on Ubuntu 18.04 LTS


The admin isn’t quite clear about this so I have a couple of questions:
Admin manual says :“On other HTTP servers it is recommended to install Nextcloud outside of the document root.”

Ubuntu 18.04 LTS
webroot: /var/www/html/
Nextcloud standard webroot: /var/www/html/nextcloud/
Nextcloud standard data directory: /var/www/html/nextcloud/data/

  1. If I use Apache2 is this OK
  2. What are the things I should be extra careful with if I do this (ie: don’t change .htaccess etc.)
  3. What is the best location for the nextcloud data directory?
  4. Is this any more secure:
    webroot: /var/www/html/
    Nextcloud webroot: /var/www/nextcloud/
    Nextcloud data directory: /var/www/nextcloud-data/

Thanks for your help!



Your webroot is /var/www/, and you’ll want to change the location of your data folder. Using the same setup, I put Nextcloud in /var/www/nextcloud/, and my Data folder in /opt/nextcloud/data. You want it outside of /var/www/.

Assuming all of the above, also make sure www-data (your web user) owns everything recursively in /var/www/nextcloud/ and /opt/nextcloud/ when you’ve finished setting things up (before launching the install wizard).

edit: Here’s a site config file for Apache that works with the above setup and has strong SSL settings.

1 Like

Thanks for your input!

I’m about to do a fresh re-install, and I’ll use your suggested configuration.




You can simply stop the server, move data directory, change path in config and start server again.