I have previously provided an in-depth explanation about NextCloud with Collabora Office Online and how we've installed it on Ubuntu 16.04. This is an update both of the process, and of the technology.
Update 2021-11-08: this post is now getting a bit long-in-the-tooth, and I need to update it to use up-to-date components. It might still be useful to folks, but use it with caution. Also, please note, we're using NextCloud with OnlyOffice (the open source community edition) these days.