To do this in the domain directory, for example:
create a .htaccess file with this content:
If your site is on a server with Litespeed, you need to add another line:
AddType application/x-lsphp52 .php5 .php4 .php .php3 .php2 .phtml
Where x-lsphp71 indicates the desired version. For PHP 5.2 specify x-lsphp52 and so on for other versions. Versions from 5.2 to 7.4 are available for selection
The list of available modules is comparable with those that are selected by default for the required version of PHP in the hosting control panel DirectAdmin, section Select PHP Version.