How to change your PHP version and upgrading to PHP 7

Change Php Version

By default, most hosting control panels have a built in PHP version switcher. You will often find all the ‘usual suspects’ including PHP 5.2 PHP, PHP 5.3, PHP 5.4 and PHP 5.5. It’s always advisable to use the most up to date version of PHP available, but because many applications, scripts and plugins may not be compatible with the latest PHP versions, the default on your hosting plan is most probably set to use one of the earlier versions.

Why change your hosting to use a new version of PHP

PHP version 5 has been around since 2004 and has seen several major updates during that time. Even today (as of publication date), PHP version 5.6 receives regular minor updates to support those not yet able to upgrade to PHP version 7. Each update brings with it a series of improvements. These improvements bring about better code stability, bug fixes and the all important security updates and patches.

One of the most popular changes is to switch your PHP to version 7. That’s right, there’s no version 6. It did exist as a development version with some long awaited features, but gained a bit of a bad reputation for being a promised update but never making it to a final release.

PHP 7 brings with it some great new features for both developers and end users alike. The best part for website owners is the significant improvement in speed. Performance wise, PHP 7 is 2x faster than PHP 5.6. Memory usage has also been optimised, making it a less hungry beast and lifting some of the strain it places upon your servers resources.

Is it safe to upgrade to PHP 7

Before you change the PHP version your website uses, it’s important to check that any applications, scripts or plugins you are using are fully PHP 7 compatible. If you’re a WordPress user, there is a plugin that aims to check the compatibility of Themes or Plugins you have installed. It’s not 100% guaranteed so it’s better to check for compatibility with the developer of any software you use.

Using a built in PHP version switcher

If you check in your web hosting control panel, you’ll most probably find a built in PHP version switcher, like the one available in our control panel – see below.

Php Switcher Version

Several versions of PHP are available to choose from. Just select the version you wish to switch to and click update to apply the change.

Php Version Switcher

Change PHP version using the .htaccess file

If you wish to use a PHP version not showing in the version switcher, chances are you can still use it providing your web host supports it. We support PHP version 7 for instance, but it’s not yet an option in the version switcher. To change to PHP version 7, we just need to make an entry in the .htaccess file.

UPDATE: PHP Version 7 is now available directly in our PHP version switcher.

Start by opening the File Manager from withing your web hosting control panel. Outside of the public_html folder, you may already find you have a .htaccess file. If not, you can easily create one by adding a new file and naming it correctly. It is important to include the dot before the name. Files that start with a dot are hidden files, so make sure your particular file manager is set to show hidden files. If you host with us, your hidden files will be shown.

Htaccess File Php Version

If you are editing an existing .htaccess file, check to see if an entry exists for the PHP version. If not, add the line below.

SetEnv DEFAULT_PHP_VERSION 70

Save the file and that’s it. You’ve updated to PHP version 7.

Alternate PHP Versions

If you discover problems when using PHP 7 or you want to set your PHP to an earlier version, you just need to change the last two numbers.

To use PHP version 5.6
SetEnv DEFAULT_PHP_VERSION 56

To use PHP version 5.5
SetEnv DEFAULT_PHP_VERSION 55

To use PHP version 5.4
SetEnv DEFAULT_PHP_VERSION 54

To use PHP version 5.3
SetEnv DEFAULT_PHP_VERSION 53

Leave a Comment

Your e-mail address will not be published. Required fields are marked *