Migrating WordPress to PHP 7

WordPress is written in the PHP programming and scripting language. The developers of PHP have stopped releasing feature updates and bug fixes for PHP 5.6 and security updates will cease December 31, 2018. Some web hosts such as WP Engine have published articles on their blog and sent emails to their customers recommending they move away from PHP versions older than PHP 7. While PHP 5.6 will still be available and continue to function, it would be wise to move to PHP 7 sooner rather than later.

PHP 7 brings new features and performance improvements that are mostly of interest to PHP developers, with the details being made available on the PHP website. For website owners, the benefits include as much as 2-3x faster code execution and improved security, providing an improved experience for site visitors. Since PHP 7 can handle as much as 3x as many requests per second and more traffic using the same number of resources compared to PHP 5.6, web hosts can accommodate more websites without added hardware expense.

Pre-flight Checks

Since speed is one of the major benefits of PHP 7, it’s a good idea to run a speed test of your website at GTMetrix, so that you can make a before and after comparison to show your boss the improvements and benefits gained by the move to PHP 7. GTMetrix will provide lots of information about your website’s performance, but for now the “Fully Loaded Time” statistic (as shown below) is the most important.

GTMetrix scan results for a slow site.

Before you make the jump to PHP 7, it’s wise to test your website’s themes, plugins and custom code to be sure there are no compatibility issues that can spell trouble for your business by way of a crashed site or pages not displaying properly. Fortunately, WP Engine provides a free PHP Compatibility Checker plugin that can check your WordPress website even if the site isn’t hosted by WP Engine. It’s also wise to make a backup of your website before installing the plugin, just as you would when installing any other plugin.

Once the plugin is installed, you’ll need to set a few options including selecting at least PHP Version 7.0, but preferably PHP 7.2. For the “Plugin / Theme Status:” field, we recommend selecting “Only scan active plugins and themes,” unless your plan is to keep unused plugins and themes. If that’s the case, select “Scan all themes and plugins.”

PHP Compatibility Checker plugin options page

Once the appropriate options have been set, click the “Scan site” button and wait for the scan to complete.

PHP Compatibilty Checker plugin scan site button

While the scan is running, it will display a spinning icon and the name of the plugin or theme currently being scanned.

PHP Compatibility Checker plugin scan progress

Once the scan has completed, the scan results will display below the scan options.

PHP Compatibility Checker plugin scan results

For any status other than “Compatible,” click the “toggle details” link to the right to access the details of the issue. Here’s an example of an error message you may see:

PHP Compatibility Checker plugin error details

You’ll need to fix a problem like this, if it’s a plugin that isn’t fixed in a way that is compatible with PHP 7. If it’s a third-party plugin, you’ll need to request that the plugin developer fix the issue or you may need to find a replacement plugin that is compatible. Then run the PHP 7 compatibility scan again.

Time to Migrate to PHP 7

Once you’re confident all code is compatible with PHP 7 and you’ve made a backup of your website, it’s time to migrate. Each web host will have its own process for handling this. WP Engine’s process is as simple as it gets. Simply log in to your WP Engine User Portal and submit a request through the Live Chat link in the top right corner of the page.

WP Engine Live Chat support

You’ll need to request that your site be converted to PHP 7. The support team will ask you to confirm your website has successfully completed the PHP Compatibility Checker scan. They will then ask you if you’d like to complete the conversion immediately or if you prefer to schedule a later time such as off-peak website traffic hours.

Once a time is agreed upon, WP Engine’s support team will create a service ticket for the request and send you a copy of the ticket via email. You will also receive email notifications when the migration is starting and when it’s completed. The migration typically happens in less than an hour, at which time you’ll receive an email notifying you the process is completed. The email will also include instructions to update your DNS entries with the settings provided. This edit will need to be completed at the domain registrar where your domain name is registered.

Final Checks

With the migration to PHP 7 completed, it’s time to verify your site is working properly. If you run into any issues, your web host may be able to reverse the migration back to PHP 5.6. WP Engine can do so easily. If the website is in full working order, it’s time to enjoy the benefits of your efforts. Visit GTMetrix and run another speed test of your website to see the improvement in the “Fully Loaded Time” statistic. It may be necessary to wait until the next day to run the test, so that the DNS changes have enough time to propagate for an accurate test.

GTMetrix fast site results

Your boss, co-workers, family, friends, cats and dogs should now be sufficiently impressed with your ability to make website optimization seem like child’s play. Life is good. To keep up your great reputation, be sure to monitor the website for at least a few more days in case Murphy’s Law tries to sneak up on you. To help you shine even more, be sure to read through the additional materials listed below.

Additional Resources