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.
AddHandler application/x-httpd-php73 .php
AddHandler application/x-httpd-php72 .php
AddHandler application/x-httpd-php71 .php
AddHandler application/x-httpd-php70 .php
AddHandler application/x-httpd-php56 .php
AddHandler application/x-httpd-php55 .php
AddHandler application/x-httpd-php54 .php
AddHandler application/x-httpd-php53 .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.
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).
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
The initial path to all PHP versions is the same.
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.