On our cPanel hosting plans, you are free to choose any PHP version from 5.1 to 8.5. However, the version set in the ‘Select PHP Version’ menu in cPanel applies to the entire hosting account, so you may need to run a website using a different PHP version within a specific folder (for example, an older application in a subfolder).
This can be done with a simple .htaccess modification.
In the folder where you wish to change the PHP version, open the .htaccess file for editing (via FTP or in the cPanel File Manager), or create it if it does not yet exist. Then enter the block from the list below that corresponds to the desired PHP version. Only enter one, as the site will return an error if multiple blocks are present. This setting applies to the specified folder and its subfolders.
PHP 5.1
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php51___lsphp
</FilesMatch>
PHP 5.2
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php52___lsphp
</FilesMatch>
PHP 5.3
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php53___lsphp
</FilesMatch>
PHP 5.4
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php54___lsphp
</FilesMatch>
PHP 5.5
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php55___lsphp
</FilesMatch>
PHP 5.6
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php56___lsphp
</FilesMatch>
PHP 7.0
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php70___lsphp
</FilesMatch>
PHP 7.1
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php71___lsphp
</FilesMatch>
PHP 7.2
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php72___lsphp
</FilesMatch>
PHP 7.3
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php73___lsphp
</FilesMatch>
PHP 7.4
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php74___lsphp
</FilesMatch>
PHP 8.0
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php80___lsphp
</FilesMatch>
PHP 8.1
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php81___lsphp
</FilesMatch>
PHP 8.2
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php82___lsphp
</FilesMatch>
PHP 8.3
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php83___lsphp
</FilesMatch>
PHP 8.4
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php84___lsphp
</FilesMatch>
PHP 8.5
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php85___lsphp
</FilesMatch>
Versions of PHP prior to 8.0 no longer receive security updates; these should only be used for legacy applications that do not run on newer versions. CloudLinux provides these older versions in a patched form (HardenedPHP), but updating the application remains the more secure solution.