Changing or Updating Your Version of PHP for WordPress
If you want to keep your website running smoothly, it’s a good idea you change or update the version of PHP it’s running on soon since PHP 7 could soon be a minimum requirement for self-hosted WordPress sites by mid-2017.
And since PHP is the programming language that forms the backbone of WordPress, this is one tutorial you shouldn’t put off.
So let’s get to it – why you need to upgrade, the possible drawbacks, and how to actually upgrade your server to PHP 7.
Why You Should Upgrade WordPress to PHP 7
If you’re running a WordPress site on your server, then you obviously have PHP already installed. So why both upgrading when everything seems to be running fine?
Here are some of the most common reasons why you should update the version of PHP on your server:
- The plugins and scripts you have installed are no longer compatible with the version you’re using
- The minimum requirements to run WordPress have been bumped up
- The version you’re using has security holes and the upgrade includes a patch
- You need to switch to a stable version
- You want to test a different version on a local installation of WordPress or on a staging site
- You found conflicts with the version you’re using and the plugins, themes or scripts you have installed
These are all valid reasons, but before you go ahead and update PHP, there are drawbacks to upgrading that you should carefully consider and plan for.
Possible Side Effects Include…
When you make the switch, it’s not all sunshine, lollipops and rainbows, unfortunately.
The main thing you need to keep in mind before you upgrade is that not all your plugins, themes and scripts are necessarily compatible with the lastest or specific version of PHP you want to use. If there’s an issue here, it could partially or completely break your site.
Each version of PHP brings on some variation of improvements, and possible fixes, security patches and structures to code. While some updates are less comprehensive than others, many versions include improvements or changes that make certain parts of older versions obsolete.
In some cases, entire versions such as PHP 4 and older are no longer supported. If you use plugins, themes or scripts on your site that rely on outdated PHP code and you upgrade to a newer version of PHP, the changes from the upgrade would cause old code on your site to be incompatible and break.
While this may not always happen, it’s important to review the changes you can expect to see in the version of PHP you want to use before you complete the upgrade. That way, you can review your site for code that wouldn’t be compatible so you can modify it to work.
Besides manually checking your site for possible pain points, there may be plugins available to automatically do a scan of your site to determine whether your site would be compatible if you upgrade.
Checking PHP Compatibility
Here are some plugins you may find helpful in your quest for PHP compatibility:
- PHP Compatibility Checker –This plugin lets you choose a version of PHP and you site is then scanned for compatibility issues. It also creates a report so you know exactly what to fix.
- PHP Pseudo Compiler – A PHP validation tool to check for undefined functions or methods.
- Error Log Monitor – If there are errors, you can enable a log to keep track of all the errors to help you know what needs fixing.
You can also enable a private error log manually by using
WP_DEBUG. You can find all the details by checking out one of our other posts Debugging WordPress: How to Use WP_DEBUG.
You can also see what has changed for each version of PHP before you upgrade:
- Migrating from PHP 4 to PHP 5.0.x
- Migrating from PHP 5.0.x to PHP 5.1.x
- Migrating from PHP 5.1.x to PHP 5.2.x
- Migrating from PHP 5.2.x to PHP 5.3.x
- Migrating from PHP 5.3.x to PHP 5.4.x
- Migrating from PHP 5.4.x to PHP 5.5.x
- Migrating from PHP 5.5.x to PHP 5.6.x
- Migrating from PHP 5.6.x to PHP 7.0.x
- Migrating from PHP 7.0.x to PHP 7.1.x
- Details on migrating to the latest version of PHP
If you find that you’re using a plugin, theme or script that isn’t compatible with the version of PHP you need, you can contact the author or a developer to help resolve the issue. If you need an extra hand, you can get in touch with our expert support heroes. If you’re a member, you can open a ticket, search the support forum or get live help.
You don’t have to worry about feeling left out if you’re not a member. You can try out a premium membership for free and ask away. Our support team is online around the clock so you can rest easy knowing you’ll get a response as quickly as possible.
Changing Your PHP Version
Once you have tested your WordPress site for compatibility, you can change the version of PHP you’re using via SSH or cPanel. If this isn’t an option for you, then contact your hosting provider. In most cases, they can apply the update for you or otherwise make arrangements.
Upgrade or Switch via SSH
Since the SSH commands for upgrading or installing other versions of PHP are different depending on the type of server your have not one set of commands can be applied universally.
Click on one of the resources below to view details based on your server type:
Keep in mind that if you use the commands provided in these links, you also need to remove the old PHP package from your server that you no longer need. Since the commands for removing older versions are also going to vary depending on your server type, consult your server’s documentation for the correct commands.
You can also check out the post Changing your PHP version for web requests for details on how you can change the version of PHP for web requests by modifying the .htaccess file.
Updating or Changing PHP in cPanel
If you prefer to pick the version of PHP for your server with a few clicks, you can do so by logging into your cPanel account. It may not be possible with all types of hosting, but if you see a PHP Version Manager button in the control panel, you’re free to make the switch when you’re ready.
It may be in different locations depending on your host, but click PHP Version Manager and navigate to the directory where your site is located that you also need to upgrade.
Choose one of the available PHP versions from the list, then click the Save button.
That’s all you need to do. Once you see a message letting you know the upgrade was successful, you’re all set.
It’s important to start thinking about upgrading your server’s PHP version for future compatibility and improved performance.
You can wait to upgrade and hope that the authors of the plugins, themes and scripts you use update, or you can search for alternatives and use those instead. Either way, it’s important to be proactive and upgrade to the latest version of PHP as soon as you can so your site doesn’t end up breaking in the future. Just be sure to test your site for compatibility issues, first.
You can also check out the full PHP manual for more details on using, installing and upgrading PHP for your server.