PHP Version and Upgrade Guide
When it comes to security and speed, upgrading PHP versions is a straightforward and invaluable way to “Press Ahead” of the competition. To help with this process, WP Engine has created a PHP Test Driver to preview a site on a new PHP version. Once that compatibility check is complete, select the new PHP version with the PHP Selector tool. No migration required. It’s as simple as that!
About PHP Upgrades
PHP is a flexible web development language that WordPress, and many other web platforms, run on. PHP is managed by a third party team of developers from around the world who maintain, update and correct the language in stable version releases. Upgrading PHP is a lot like updating plugins or themes; it makes the site perform better and run more securely.
Each PHP version is provided support by its developrs for 2 years after the initial release date, to receive improvements, bug fixes and security patches. After those first 2 years a PHP version will only receive critical security updates, as-needed. After 3 years, the PHP version is deprecated and no longer receives updates, making it not supported and insecure.
At WP Engine, we want you and your visitors to have the fastest and most secure WordPress hosting experience. One of the most easily changed factors to improve a website’s performance and security is by updating the PHP version.
For example, in upgrading a website on WP Engine from PHP 5.6 to 7.2 we saw speed improvements of up to 40%. From 7.2 to 7.3 we saw as much as 15% faster page transaction times. With 7.4, we saw around 10% performance improvement after upgrading!
Automatic PHP Upgrades
The EOL (End-Of-Life) process is a standard part of the release cycles of PHP (the open source programming language which powers WordPress). Once a version has reached “end of life”, PHP ceases to provide security support for it and it is no longer secure enough to remain on WP Engine servers.
For security purposes, WP Engine completely removes older versions of PHP from our servers once they have reached “end of life”. At this time, if your website is using an older version of PHP, it will be upgraded to a newer version automatically.
Our team will notify technical contacts via email several times before this automatic change occurs. We highly recommend updating as soon as possible when a new PHP version is released to ensure the site is receiving performance benefits as well as to ensure the update can be performed before an automatic upgrade occurs. Automatic PHP upgrades cannot be deferred.
Supported PHP Versions
If a new PHP version is not available for an environment, it will be soon. We roll out all new versions slowly to the WP Engine farm as a security precaution. If a new version is needed more quickly, a migration may be necessary (which can cause downtime and DNS updates). In most cases, it’s considered easiest to wait for the rollout process to complete.
View Current PHP Version
There are several options to check the current PHP version on a WordPress website:
- The easiest way to see the PHP version on an environment is to view the current setting of the PHP Selector in the User Portal.
- Use a plugin such as Display PHP Version to show the current PHP version from within the WP Admin.
- Create a PHP Info page for the environment (more details below).
PHP Info Page
A phpinfo page can be used to view the current PHP information for an environment. This can be useful for debugging PHP related issues while developing or maintaining a WordPress site.
- Create a file using a text editor
- We recommend naming this file a random string, for security purposes.
- The file must be saved with the .php extension.
- Paste either of the following file contents in to this new file and save it:
To find PHP version information:
<?php echo 'Current PHP version: ' . phpversion(); ?>
To know information about which PHP modules are loaded:
<?php phpinfo(INFO_MODULES); ?>
- Connect to the site using SFTP
- In the root directory, drag and drop the newly created file
- In the browser, type te domain followed by the filename
It is highly recommended to delete the file as soon as possible after use, for security reasons. Leaving this file on a website can create an unintended vulnerability by publicly exposing the server’s PHP configuration.
Test PHP Version
There are several options for testing prior to upgrading a live site. Perform one or all of these options, as desired, to ensure the website’s success.
- Use the PHP Test Driver
- Copy to a Staging or Development environment and upgrade PHP independently
- Each environment can have a different PHP version using the PHP Version Selector
Deprecation notices in the site error logs following a PHP upgrade refer to PHP features that are being replaced by different, updated features. With every new PHP version, there are some deprecated functions and elements. These aspects of the website will typically work for now, but will be removed in later versions of PHP, giving developers time to update their code. A list of deprecated features, as well as their recommended modern solutions, on the official PHP website.
PHP Test Driver
The PHP Test Driver can be used to view the website on a different version of PHP. After logging in to the website, a special cookie is applied to the session which allows only your browser to see the site on that PHP version. Other visitors continue to see the site as normal without disruption. If the Test Driver is working, there will be a “Test Drive” banner in the WP Admin. The Test Driver functionality will work for WordPress users at the Editor role or above, and will be cleared when the session ends or cache is cleared.
Enable PHP Test Driver
- Log in to the WordPress admin dashboard when prompted
- A banner will display at the top of the screen indicating an alternate PHP version is active:
- Click through the website as desired to test functionality
To test multiple versions of PHP, the cookie must be cleared between versions. A new incognito session can be used for each PHP version being tested, as cookies are deleted automatically when ending an incognito session.
For best practices on testing the compatibility of websites with a new version of PHP, please see WP Engine’s recommended developer workflow.
The PHP test driver will not automatically work on subsites within a multisite network. If logged in as an admin, the query
?wpengine_php=7.3 (or any other supported PHP version) can be added to the end of a URL to enable that alternate PHP version for testing.
Disable PHP Test Driver
A cookie is set in your browser that will continue to show the site in the selected version of PHP. This cookie will expire after a day on its own or after closing the browser.
To disable the Test Driver manually, there are three options:
- Click the link within in Test Driver banner in the WordPress admin dashboard:
- Delete a cookie from the browser called: wpengine_php
- Delete all cookies from the browser
Change PHP Version
Changing PHP versions is quick and easy, requiring no technical knowledge. The change is in-place meaning there is no migration, no downtime and no DNS updates necessary.
PHP version can vary between environments, regardless of server or account. This means environments can be upgraded as they’re ready to go. Keep in mind that PHP version is not duplicated when copying environments, and it will need to be modified using the PHP selector in the User Portal.
An environment can be upgraded or downgraded between any of the available PHP versions as-needed. Once a version is retired from WP Engine servers, the website will be automatically upgraded to a newer version. We recommend upgrading to each new version of PHP as soon as possible.
The PHP Selector can change the version of PHP an environment uses and is available at two locations in the User Portal.
Overview Page PHP Selector
- Open the Sites page in the User Portal
- Select the environment name
- Within the Updates section, locate PHP
- Click the PHP Version number
- Select a new PHP version
- Click Confirm
The PHP version on this environment will be changed in just a few moments. When version change is completed, we recommend verifying everything is as it should be on the website.
Troubleshoot PHP Errors
In some cases, a PHP upgrade may break a website. If the previous version of PHP is still available on the server, the PHP selector can be used to switch back temporarily. We highly advise reaching out to the plugin/theme authors or a developer for guidance resolving errors, as switching to an older PHP version is not a permanent solution.
- Copy to staging/development environment
- On a test environment, upgrade plugins, themes and WordPress core files
- Many premium themes and plugins may not show an update available in the WP Admin, so be sure to check with the author directly.
If there issues, start ruling items out in order to locate the culprit:
- Disable plugins one at a time
- Enable a default theme
- Reinstall default WP Core files
- Update plugins and themes
Additional troubleshooting options:
- Accessing site error logs
- Understanding PHP error messages
- Resolving a 500 internal server error
- Troubleshooting using SSH Gateway
Need development help?
WP Engine Consultants – Directory of well-known WordPress consultants.
If you still need guidance for determining which item(s) may be causing errors, reach out to our Support team. Bear in mind, WP Engine Support team members are not trained developers and cannot modify code on your behalf.