To do this in the domain directory, for example:
domains/domain_name/public_html
create a .htaccess file with this content:
<FilesMatch “.(php4|php5|php3|php2|php|phtml)$”>
SetHandler application/x-lsphp71
</FilesMatch>
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.