I am not aDietpy specialist but since it is a debian based os, you could try this.
Run this command to control, if all php-versions are switched to the version you want. I would recommend to not leave it in automatic mode but choosing the respective manual mode so that no unintentional version changes can take place, but only after your conscious change (using this command):
for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done
If this does not work for you, don’t’ hesitate to ask me.
If you need further help or information e.g. about what php-sapi you could use. I will do my best helping you.
Sorry for late response.
I tried it, but it doesn’t work.
I downloaded the original image of nextcloud and put it to run.
I was trying to use DietPi because it has a fame of be a very lightweight system, but unfortunately, time is money. LOL!