PHP 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.
To see when a PHP upgrade occurred, and who made the change, view the Account Activity page in the User Portal.
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 old versions of PHP from our servers once they have reached “end of life”. When a version of PHP reaches end-of-life, WP Engine will automatically upgrade all websites to a more current version. Automatic PHP upgrades cannot be deferred.
Because PHP version changes can break functionality on your website, we highly recommend updating PHP as soon as possible when a new version is released. This will also ensure the site is receiving upgraded performance and security benefits. Our team will notify technical contacts via email several times before this automatic change occurs.
NOTE
Ensure each website’s Technical Contact is up-to-date to receive PHP upgrade notifications.
Supported PHP Versions
7.4 8.2
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 require a DNS update). In most cases, it’s considered easiest to wait for the rollout process to complete.
NOTE
WP Engine is offering a temporary period of extended support for PHP 7.4. Learn more here.
View Current PHP Version
There are several options to check the current PHP version on a 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 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.
- EX:
a7d8s9gj3.php
- 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
- EX:
http://domain.com/
a7d8s9gj3.php
- EX:
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 wp-admin users at the Editor role or above, and will be cleared when the session ends or cache is cleared.
Enable PHP Test Driver
- Open the Sites page in the User Portal
- Select the environment name
- Click Preview PHP
- 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=8.2
(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 recommends the following development partners: Codeable, First Internet Digital Marketing
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.