InMotion Hosting Support Center
Discussions on this article:

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

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

PHP 5.5

# Use PHP 5.5 as default
AddHandler application/x-httpd-php55 .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.

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.

Support Center Login

Social Media Login

   
Social Login Joomla

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

Question: Is php 5.5 supported?

n/a Points
2014-05-29 10:37 am

Can you update this article and add php 5.5 as well?

AddHandler application/x-httpd-php55 .php

Staff
11,186 Points
2014-05-29 10:45 am
Yes, you are able to use this for 5.5 as well.
n/a Points
2014-05-29 10:39 am

This is outdated, can you update your article?

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.

One of your Support Reps just told me this:

The PHP switcher should work for 5.5, if using suPHP.

Staff
11,186 Points
2014-05-29 10:48 am
You can now go to a higher version using this method as well. I have updated the article to remove this warning.
n/a Points
2014-07-18 4:47 pm

Doesn't work...doing this just starts giving me download boxes for all of my files. This article needs to be updated.

 

I used AddHandler application/x-httpd-php55 .php

 

n/a Points
2014-07-21 11:55 am

Please disregard - for others experiencing the same issue, I had to call support and request this feature to be added (VPS). It is now working properly.

n/a Points
2015-06-23 2:26 pm

I am having the same problem that Bryan was, only my support told me I had to do it myself.  My default php is 5.3, but I want to use 5.4 or higher on a directory.  Whenever I change the .htaccess I get download boxes.  What am I doing wrong?

Staff
5,323 Points
2015-06-24 1:01 am
Hello Daniel Titus,

I do apologize for that response as it was not deserved. Generally when you get the download boxes then either the server is not configured to allow multiple PHP versions or the software you are running is specific to the version you are one. All of our shared servers are able to move between PHP versions within the cPanel.

Best Regards,
TJ Edens
n/a Points
2015-06-24 7:32 am

TJEdens,

Thanks for your comment.  I am on a dedicated server.  I had to go through the WHM to change the PHP, but that broke most of the installs on that server.  Does this (being on a dedicated server) indicate that I cannot run multiple versions of php?

Thanks again,Daniel

Staff
26,266 Points
2015-06-24 3:12 pm
Hello Daniel,

Sorry for the ongoing issue with the PHP version change. As long as you are using suPHP, then you can request that the option be added to your server. You would need to submit a ticketed request to live technical support team and they can do that for you. This would add the option to your cPanel to switch between the PHP versions.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2015-06-25 6:56 am

Arnel,

Thanks for your reply.  It didn't dawn on me until far too late that I have created some confusion.  I appreciate the help of the inmotionhosting.com staff, but I am actually hosting with someone else.  (They refered me here when I asked for help.)  I creaeted a phpinfo.php file which says the Server API is CGI/FastCGI.  That means it's using suPHP, right?

I greatly appreciate all of the help,Daniel

Staff
17,917 Points
2015-06-25 10:34 am
Hello Daniel,

Thank you for contacting us, we are happy to help. Yes, that is correct. If the "Server API" lists CGI, then suPHP is installed.

If you have any further questions, feel free to post them below.

Thank you,
John-Paul

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

12 Questions & Comments

Is php 5.5 supported?

Post a comment

Back to first comment | top

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!