Install with snap
sudo snap install nextcloud
Set user and password for NextCloud
sudo nextcloud.manual-install nextcloudadmin password
Allow https access for firewall
sudo ufw allow 80,443/tcp
For the following steps to work, you’ll need an A record setup on your domain name server to point a domain to your Next Cloud servers public ip address. Change www.example.com in the following steps to the domain name you’ve setup.
View trusted domains
sudo nextcloud.occ config:system:get trusted_domains
Setup new trusted domain. Change www.example.com with your domain.
sudo nextcloud.occ config:system:set trusted_domains 1 --value=www.example.com
Run through Lets Encrypt to setup a SSL certificate.
sudo nextcloud.enable-https lets-encrypt
Should be able to access NextCloud from a web browser www.example.com
Extra info
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-nextcloud-on-ubuntu-18-04