Using Multiple PHP Versions InMotion Hosting ContributorUpdated on August 15, 2023 3 Minute Read When using different software on one account, you may need to use one version of PHP while running multiple PHP versions on different domains. For example, you can have PHP 5.4 for the site in public_html and then use PHP 5.2 in a subdirectory. Here is how to use any combination of other PHP versions in any directory when web hosting with PHP. Using the Default PHP version To use the system default PHP, use the following in .htaccess: # Use system PHP5 as default AddHandler application/x-httpd-php5 .php .php5 This will make the specific directory use the System’s default PHP version. Using Multiple PHP Versions Depending on what version of PHP you want to use, you will need to place the following code in the .htaccess of the directory you want to change the PHP version for. Below is the code you need for each PHP version. PHP 5.3 # Use PHP 5.3 as default AddHandler application/x-httpd-php53 .php .php5 PHP 5.4 # Use PHP 5.4 as default AddHandler application/x-httpd-php54 .php .php5 PHP 5.5 # Use PHP 5.5 as default AddHandler application/x-httpd-php55 .php .php5 PHP 5.6 # Use PHP 5.6 as defaultAddHandler application/x-httpd-php56 .php .php5 PHP 7.0 # Use PHP 7.0 as defaultAddHandler application/x-httpd-php70 .php .php5 PHP 7.1 # Use PHP 7.1 as defaultAddHandler application/x-httpd-php71 .php .php5 PHP 7.2 # Use PHP 7.2 as defaultAddHandler application/x-httpd-php72 .php .php5 PHP 7.3 # Use PHP 7.3 as defaultAddHandler application/x-httpd-php73 .php .php5 PHP 7.4 # Use PHP 7.4 as defaultAddHandler application/x-httpd-php74 .php .php5 Once you add the appropriate version code to your .htaccess your site in that directory will use that version of PHP. Important! If you have PHP errors after adding the .PHP version code to the directory .htaccess, you may need the php.ini for that particular version uploaded to the directory and the recursive path added in order for the correct version of the php.ini to load. If there is no php.ini specific to the version of PHP you are using in the directory where the version code is added, the server will use the default php.ini. This could cause a newer php.ini version to be used instead of the older php.ini version, which can cause an issue in some cases. Using a PHP specific version of php.ini. The following code will direct the server to the particular php.ini file. In this case, the path goes to the public_html directory. This is called the recursive path. suPHP_ConfigPath /home/USER/public_html To point your domain to a php.ini in a subfolder you would do the following: suPHP_ConfigPath /home/USER/public_html/foldername This allows a php.ini to be stored in the subdirectory, particularly for your PHP version in that directory. Note! If you need an older version of the php.ini file restored to a specific directory, you can specify the path to whatever version you are looking for like the following. suPHP_ConfigPath /usr/local/lib suPHP_ConfigPath /opt/php52/lib suPHP_ConfigPath /opt/php54/lib Otherwise, you can contact tech support to have them restore the specific php.ini version to the folder you need it in. Using the MultiPHP Manager to Change the PHP Version Checking your changes You can check to see if any changes you made took place by placing a phpinfo page in the folder area you are working on. You can then view the settings to ensure they are set correctly. Share this Article Related Articles Intro to Migrating your WordPress Site Data Migrating your WordPress Database Migrating WordPress Files Configuring WordPress After a Migration Testing your WordPress website after Migration How to Move WordPress from a Subfolder to the Root Directory What to expect during a mass server migration Move Your WordPress Site to a New Server Moving Websites Built with Older Technology into WordPress How to Export Your WordPress Sites