How to use web installer?

I do:

mkdir ~/nextcloud
cd ~/nextcloud
curl -O https://download.nextcloud.com/server/installer/setup-nextcloud.php

Then what do I do with setup-nextcloud.php?

I tried php -f setup-nextcloud.php but this ain’t doing anything

Open it in a browser:

https://cloud.server.tld/setup-nextcloud.php

Ok, but should there be some apache2 configuration associated with it? Does nextcloud provide it or how it meant to be exposed?

No, you need to put the installer into the web root, or a sub directory of the web root, of an already running web server. On Debian based systems, the default web root (or DocumentRoot as the configuartion directive is named in Apache) of a freshly installed apache2 package is /var/www/ or /var/www/html.

Btw, you also need to install and enable all the necessary PHP modules, in order for it to work.