On the Crucial Hosting managed platform, we offer many different versions of PHP. You are able to choose which version you want to use at any time, since all of the PHP versions are available on all of our servers. As long as you have a Split-Shared, Split-Dedicated, or Managed Dedicated Server, then you can use the information below.

Changing your PHP version for web requests

The best way to change the version of PHP used for requests to your website is to add one of the following lines to your .htaccess file. One major convenience of this method is that you can change the PHP version for individual directories.

PHP 7.0

AddHandler application/x-httpd-php70 .php 

PHP 5.6

AddHandler application/x-httpd-php56 .php 

PHP 5.5

AddHandler application/x-httpd-php55 .php 

PHP 5.4

AddHandler application/x-httpd-php54 .php 

PHP 5.3

AddHandler application/x-httpd-php53 .php 

PHP 5.2

AddHandler application/x-httpd-php52 .php 

The default version of PHP for web requests

With very few exceptions, the default version of PHP on our servers is PHP 5.3. This is because many customers still run software which hasn't been updated to support anything more recent.

On our Split-Dedicated or Managed Dedicated Servers, you can change the default version of PHP in cPanel. We've created a custom tool to allow you to make this change. To do this, go to "PHP Config" in cPanel, and then Select the Version of PHP you prefer. Once you've picked the preferred PHP version, select "Set as Default PHP".

Making sure you are on the right version of PHP

The easiest way to do this is to simply make a "PHP Info" file. It's simple to do. Just make a file and name it something like myphpinfo.php, or anything that ends with .php. Then just simply place the following line of code in the empty file.

<?php phpinfo();?>

Once you've created and saved that file, you need to view it in your browser. Once you view the file in your browser, you'll see the PHP version at the top of the page.

An advanced approach to PHP versions and .htaccess regular expressions

For more advanced web applications, you may find yourself in a situation where multiple scripts in the same directory require different PHP versions. In that situation, you can use the "Files" or "FilesMatch" directive in your .htaccess file. The example below looks for URI requests that contain "mynewscript", and uses PHP 5.5. In the event the URI contains "mynewerscript", it uses PHP 5.6. If neither of these are matched, it uses the default PHP version (or whatever is set above this in this in the .htaccess file.)

<Files ~ "mynewscript">
AddHandler application/x-httpd-php55 .php
</Files>

<Files ~ "mynewerscript">
AddHandler application/x-httpd-php56 .php
</Files>

Picking a PHP version for command line and cron scripts

The way you would typically call a PHP script is by starting your command with "php". As an example, the following line will let you see the default version of PHP on your server (for command line only).

php -v

Now many scripts may require you to run a different or more recent version of PHP. That's easy to do. As an example, you can replace "php" with "php-54" to request PHP 5.4. Below are some examples of how to call the various versions of PHP.

Default PHP Binary

php -v

PHP 5.4

php-54 -v

PHP 5.5

php-55 -v

PHP 5.6

php-56 -v

PHP 7.0

php-70 -v

The initial path to all PHP versions is the same.

/usr/local/bin/

When you need the full path to the PHP version of your choice (cron, scripts, etc) simply use the the path above with the correct PHP binary. Example: For PHP version 5.5 you would use /usr/local/bin/php-55.

Changing the version of PHP for the default "php" binary

If you are on a Split-Dedicated or Managed Dedicated Server, we can change your default PHP version for the command line. Please understand that this will affect every PHP request on your entire server. You can create a ticket in our support center, and we'll make this change for you.