Weren't there files & directories that require the www-data:www-data to be the owner?

So I just changed the OS of my server from Raspbian to Ubuntu 19.10 on my Raspberry Pi, along with a new 6TB WD Red, which I migrated my data to.

I was getting an internal server error, and I don’t know exactly how I solved it, but I thought that switching the entire Nextcloud data to www-data:www-data would solve it (along with 750). However, when I recursively changed the owner to root:root, that solved it. However, I remember there were folders that were owned by www-data:www-data, when I was still using Raspbian. Did something change?

Both the nextcloud installation directory and the data directory (which should be separated) must be owned by the user that runs the web server. In both Raspbian and Ubuntu that is www-data. Say Nextcloud is installed in /var/www/nextcloud and the data directory is in /var/lib/nextcloud/data,

sudo chown -R www-data:www-data /var/www/nextcloud
sudo chown -R www-data:www-data /var/lib/nextcloud/data