If you get an error message on installing Moodle that the script is not compatible with your version of PHP, there will be an option to change it with the error.
For example, at the date of this tutorial, Moodle 4.0.4 is incompatible with the latest version of PHP (8.1.0+) and requires an earlier version.
To fix it, tick the select box, and click the “Quick Install” button.