Page tree
Skip to end of metadata
Go to start of metadata

Recently, we have had clients ask how to run different PHP versions in the same cPanel account. Unfortunately, this is not available with the PHP Selector at the time of this writing, but there is still a way to achieve this on the server with CloudLinux and PHP running in suPHP mode.

To use a specific version of PHP in a particular directory, just add a line to .htaccess in that directory (or create an .htaccess file with that line, if it is not there).

For example for php 7.3, add the following line in .htaccess will be:

-Subdirectories will use the same PHP version as the parent directory unless you override it with another .htaccess entry in that subdirectory.

-PHP extension selection will match the extensions selected by end user for that PHP version in PHP Selector.

-Some modules may not be enabled, you may need to add them in your php.ini. For example, if you see something like MySQL module is not enabled, you need to add into your php.ini the following:

extension=pdo_mysql.so
extension=pdo.so
extension=mysqli.so
extension=mysql.so

-This is not an ‘officially’ supported way to run multiple PHP versions per account, but it is a safe hack that will work for anyone using suPHP.