If you are using different types of software on your hosting account, there may be a need to use more than one version of php. For example, maybe the primary website needs php version of 5.2 and an addon domain may use software that requires 5.4.

You can use as many versions of php on your site as you need. Below is a sample of different folders on an account and the different php versions they require.

public_html needs php version 5.2
public_html/addondomain.com needs php version 5.4
public_html/example.com needs php version 5.2

Note that you can only use php versions that are older than the version on your server. For example if the server version is 5.4 you cannot set one area of your site to use 5.5. You can, however use 5.4, 5.3, 5.2, etc...

The Default PHP version

You can use the system default PHP version b adding the following code to your .htaccess file.

# Use system PHP5 as default
AddHandler application/x-httpd-php5 .php

How to change the version on a directory basis

You can change the PHP version in any directory you choose. You just need to create a .htaccess file in that directory and enter the appropriate code for your desired PHP version.

PHP 5.2

# Use system PHP5 as default
AddHandler application/x-httpd-php52 .php

PHP 5.3

# Use system PHP5 as default
AddHandler application/x-httpd-php53 .php

PHP 5.4

# Use system PHP5 as default
AddHandler application/x-httpd-php54 .php
You may experience PHP errors after adding your specific php version to the directory .htaccess file. In these cases, you will want to use the php.ini file that is specific to your version.

Using the versions specific php.ini file

If you do not have a php.ini file for the directory you have declared a php version for, the server will attempt to use the system default php.ini. This may cause a newer version of PHP to be used instead of the one you have declared. You will want to set the server to a particular php.ini file. The code samples that follow go into the .htaccess file and define the specific path for the php.ini to be used.

This code tells the server to use the php.ini file located in the public_html folder. This would be for your primary domain name.

suPHP_ConfigPath /home/USER/public_html

To point to an addon domain or other subfolder, you will use code similar to the following...

suPHP_ConfigPath /home/USER/public_html/subfoldername

This method allows you to store a php.ini file that is specific to your version. It is recommended to have a php.ini file for each separate version even if it works with the same file in case you need to make any customizations for that specific instance.

If you wish to use a php.ini file for an older version of php. you can specify the php.ini by using one of the paths below:

suPHP_ConfigPath /usr/local/lib
suPHP_ConfigPath /opt/php52/lib
suPHP_ConfigPath /opt/php54/lib

If you wish to have a copy of these specific php.ini files in your directories, please contact our Live Support team to have them copy it over for you.

Confirm your changes

After completing any setup or making any changes, be sure to check and confirm that the settings are correct. You can do this by viewing the settings in a phpinfo page for your directory.

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 this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Post a Comment

Email Address:
Phone Number:

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

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!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

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

Not a Customer?

Get web hosting from a company that is here to help.