I just installed nextcloud and because of
You should locate your Nextcloud data directory outside of your Web root if you are using an HTTP server other than Apache, or you may wish to store your Nextcloud data in a different location for other reasons (e.g. on a storage server).
what I found in the administration manual on the page of the Installation wizard, I didn’t change data directory because I’m using Apache.
Now I wanted to fix some security issues and I found in the “Hardening and Security Guidance” this
Place data directory outside of the web root It is highly recommended to place your data directory outside of the Web root (i.e. outside of /var/www). It is easiest to do this on a new installation.
My question is:
Is it always better to place the data directory outside web root?
Why is it save with apache but not save with the other web server?