When using different software on one account, you may need to use an older version of PHP while running a newer version of PHP on a different domain. For example: You can have PHP 5.4 for the site in public_html and then use PHP 5.2 in a subdirectory. You can use any combination of older PHP versions in any directory on the account.

Important! If you just want to change the version of PHP site wide you can follow the steps by clicking here.

Below is an example of having multiple directory locations using different versions on PHP. The following example shows the "public_html" is using PHP 5.4, the "public_html/othersite" using PHP 5.2 and so forth.

public_html 5.4
public_html/othersite: 5.2
public_html/someothersite: 5.3
public_html/someothersite/yetanother: 5.4

Important! You can only go backwards. You cannot use a newer version of PHP on an older PHP server. You will need to have newest version of PHP on the server to do this.

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

This will make the specific directory use the System default PHP version.

Changing the PHP version per directory

Depending on what version of PHP you want to use, you will need to placed 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.2

# Use PHP 5.2 as default
AddHandler application/x-httpd-php52 .php

PHP 5.3

# Use PHP 5.3 as default
AddHandler application/x-httpd-php5 .php

PHP 5.4

# Use PHP 5.4 as default
AddHandler application/x-httpd-php54 .php

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 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.

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/USER/public_html
</IfModule>

To point your domain to a php.ini in a subfolder you would do the following:

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/USER/public_html/foldername
</IfModule>

This allows a php.ini to be stored in the sub directory 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.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Write New!
Do you want to publish a tutorial to our support center?

News / Announcements

SSL Certficate Warnings
Updated 2014-04-14 11:34 am EST
Hits: 2013
Heartbleed 0-day OpenSSL security bug
Updated 2014-04-14 04:43 pm EST
Hits: 5300

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!