If you're using Nextcloud All In One then it's easy to enable it in the AIO settings.
If you're not, I suggest looking into it. It's the new officially recommended way of installing and it's been great.
Nextcloud has an export/import data function but at the time I did it I only had a few GB of data so not sure how well it scales.