Sunday, April 26, 2020

Upgrade WordPress to PHP 7 How to Do It Safely

PHP 7 offers one of the biggest jumps in performance weve seen so far from this particular software. If your web server is still running a previous version, you may be holding your site back from working as well as it could. The only problem is that learning how to upgrade WordPress to PHP 7 can be a little tricky.Despite that, upgrading your site to the latest version of PHP is a smart move, and one that will benefit you in a number of ways. Plus, the process isnt actually that difficult as long as you go about it safely, to ensure that the update wont break any of your sites elements. That way, you wont have to rush around fixing things afterward.In this article, were going to talk about what PHP 7 is and why you should make the switch. Then well teach you how to upgrade WordPress to PHP 7 safely, in just four steps. Lets get to it! PHP 7 offers some massive upgrades for end users. For example:You should see about a 50% performance increase after making the switch.  PHP 7 offers a huge performance boost thats well worth the upgrade.It supports 64-bit Windows systems.  Most people use Linux for their servers, but if youre a Windows user, youll appreciate the new support for 64-bit operating systems.Plus, PHP 7 is now the official recommended PHP version for WordPress.If your primary concern is that installing PHP 7 will break your site in some way, then weve got your back. Theres always some risk involved in an upgrade like this, but there are also ways to carry out the process safely.How to safely upgrade WordPress to PHP 7 (in four steps)Before we go any further, lets talk about how the upgrading process works. If you have full privileges on your server, you can upgrade WordPress to PHP 7 using your command line. On the other hand, if youre on shared or managed hosting, youll probably have to ask your providers support team to upgrade your site manually.In either case, the actual process is straightforward. The problem is that if you dont take any precau tionary measures, you run the risk of breaking elements of your site that dont play nicely with PHP 7. Thats why were partial to a different approach that enables you to eliminate most of the risk involved.Step #1: Back up your websiteBacking up your site regularly is something you probably already do. However, youll want to have a backup of your site thats as recent as possible.Youll be using this backup to create a copy of your site, where you can test how everything works with PHP 7 without causing any damage to your live site. If a plugin ceases to work, for example, youll know you have to look for an alternative before you upgrade your real WordPress site to PHP 7.For this step, we recommend using the UpdraftPlus plugin, since its one of the most straightforward backup solutions available. Install and activate it now, and then go to the  Settings → UpdraftPlus Backups  tab:Once youre in, click on the  Backup Now  button, and choose to include both your database a nd files in your backup:Give the plugin a couple of minutes to back up your site, or possibly more (depending on how large your site is). When its done, youll find your new backup files under the  Existing Backups  tab:Now, youll want to click on the following four buttons in turn: Database, Plugins, Themes, and Uploads. This will give you the option to download copies of each file to your computer:When youre done, you should have four files containing your entire website. Now youre ready for the next step.Step #2: Create a local staging copy of your siteThere are plenty of ways to create a staging copy of your website, but were partial to Local by Flywheel because its easy to set up. Plus, you dont need to be a Flywheel customer to get the app. Just go to the website, fill out a short form, and download the tool.After installing Local by Flywheel, youll be able to add new local websites to your roster by clicking on the plus sign in the lower left-hand corner of the application :Do so now, and youll be prompted to choose a name and an environment for your staging site. When you get to the environment part, select the  Custom  option:This will give you the choice of using PHP 7 for your staging website instead of 5, which is the default setting. Make sure you choose the right version, and then create an admin name and password for your site. After that, sit back while the app sets everything up.Once your new staging website is ready, look for it under the list of local sites on Local by Flywheels main screen. Then click on the  Admin  button that will show up next to its description, to access your dashboard:(Note; if you need some hands-on guidance on how to use Local by Flywheel, weve got a whole tutorial on that. Check it out.)The first thing youll want to do here is install the UpdraftPlus plugin once more. When its running on your staging site, return to the  Settings → UpdraftPlus Backups  tab and look for the option that reads  U pload backup files:Now, drop the four backup files you downloaded earlier into the designated area. When the upload is complete, youll see your backup appear on the list. Click the  Restore  button next to it, and youre in business.Step #3: Test your staging siteWhat youve just done is created a staging website thats a perfect copy of your original site in every way,  except  for the fact that this one is running PHP 7.Now comes the part where you look for errors on your staging site. What youre looking for and what issues you might find will vary widely depending on your unique setup. However, heres how we recommend you go about conducting your test:Make your way through every page on your website, looking for any elements that have suddenly stopped working.Check to see if your plugins are behaving as they should, one by one.Test any features that your active theme includes, to ensure that theyre still functioning.This might take a little time, depending on how large your w ebsite is. If you run into any broken plugins or themes, its worth looking for replacements, since PHP 7s benefits are well worth making a few changes.Step #4: Upgrade your live site to PHP 7If you didnt find any errors on your staging website (or after youve identified the source of any problems that do appear), all thats left is to upgrade your live site to PHP 7. As we mentioned earlier, this process is rather simple. There are two ways to approach it, depending on your host:If you use a Virtual Private Server (VPS) or any other hosting option that gives you full control, you can upgrade WordPress to PHP 7 from the command line.If your host doesnt give you this level of access, you can ask them to upgrade you to the latest version through their support system.When youre done, be sure to test your sites performance again (just to be safe). Then you can start enjoying the improvements PHP 7 provides!ConclusionPHP 7 has been around for a while now, yet adoption rates are nowhere nea r where they should be. This new version offers a marked increase in performance, and most reputable web hosts will give you the option to upgrade WordPress to PHP 7. If yours doesnt, then its probably time to choose a new WordPress host. Back up your website.Create a local staging copy of your site.Test your staging site to ensure that everything is working as it should.Upgrade your live site to PHP 7, and test it again.Do you have any questions about how to upgrade your site to PHP 7 safely? Lets talk about them in the comments section below!Free guide5 Essential Tips to Speed Up Your WordPress SiteReduce your loading time by even 50-80% just by following simple tips.