what to know before upgrading php

This article is part of HostGator’s Web Pros Series. In this series, we feature articles from our team of experts here at HostGator. Our Product Managers, Linux Administrators, Marketers, and Tech Support engineers share their best tips for getting the most out of your website.

PHP released a new version recently, and you may be wondering if you should upgrade your website now. In fact, you may have questions about how to upgrade and even why it matters. 

Before you make any changes to your site, check out our answers to the most common questions we get about PHP upgrades. You’ll find the info you need to help you decide whether you should upgrade, how to upgrade safely and why it’s important.

What exactly is PHP?

PHP is a hypertext processor that’s used with HTML to create scripts for websites. When you visit a website, your browser sends the site a request, and PHP scripts compile the HTML packets to send them back to the browser. 

PHP is used by 79% of websites whose server-side language is identified. It’s also one of the best maintained languages, because new updates and new features are constantly being pushed out. Version changes happen about once every year. That brings up the question, what do you need to do to ensure that the new updates are right for your website?

How do I know which version of PHP my site is or should be running?

If you’re a HostGator customer, you’ll find a MultiPHP Manager tool in your cPanel. This allows you to see what versions of PHP you can use. 

cPanel MultiPHP Manager Plugin

You can also create a phpinfo file in your site’s file manager and use that to display your version of PHP. For example, let’s say you name your file phpinfo.php. Then you can go to your website and enter /phpinfo.php at the end of your site’s URL, and it will show you what version of PHP you have. 

Do I really need to keep my site’s PHP upgraded?

Upgrading and maintaining a current version of PHP is important for the security of your website. With each new PHP version, there are new security features that get implemented. At the same time, older PHP versions that have reached their “end of life” get no updates for security or any other features. 

So, if a new vulnerability pops up that affects any of those old versions of PHP that aren’t supported anymore, that vulnerability won’t get patched. That leaves your website open to potential attacks.

Will upgrading PHP cause something to break on my website?

It might, unless you do your research and planning before you upgrade. Here’s why. 

Whenever there’s a new version of PHP, old features get what we call deprecated. That means those old features are no longer supported and they’re getting phased out of future versions entirely. So, it seems like upgrading whenever a new version comes out would be the logical thing to do.

However, if your site runs on WordPress, your version of WordPress has its own requirements for the version of PHP it can work with. And every WordPress plugin you have installed on your site has its own PHP requirements, as well. WordPress and its plugins are typically coded to work with specific versions of PHP, so you need to make sure that your plugins and WordPress are developed for the same versions. 

You might update WordPress and your plugins but not PHP, and then discover that you need a newer version of PHP. Or you might upgrade to a new version of PHP and discover that it’s too new if you haven’t upgraded your version of WordPress and your plugins in a while. 

If there’s a mismatch between the version of PHP you’re running and the version your WordPress and plugins are written to work with, you’ll get deprecation errors saying that piece of code is no longer supported or has been removed in the version of PHP you’re using.

What’s the best way to upgrade PHP?

First, before you make any software changes on your website, it’s wise to make a backup of the current version. That’s the most important thing you can do to ensure you have something to fall back on in case your updates break something on your site. 

Keep in mind that it’s easy to roll back to an earlier version of PHP, but it’s not always easy to roll back software updates. It’s important to do your research beforehand and make sure you have your site backup before you begin.

Before you upgrade PHP, always start by reviewing your version of WordPress and your plugins. That’s a best practice mostly because software developers tend to code for longevity, and they want to make sure that their code is compatible with multiple versions of PHP. You need to know which versions those are.

It’s also a good practice to check the documentation for WordPress and the plugins you’re using to ensure that your system meets the requirements of the PHP version that you want to install.

After you’ve checked to make sure the upgrades you’re planning are compatible, upgrade the WordPress and plugin software first and then check for problems. If everything works, then you can upgrade PHP and check your site again. If that upgrade breaks something on your site, you can roll back to your previous version of PHP.

What version of PHP does HostGator support? 

HostGator offers PHP 5.4 through PHP 7.4 on its shared hosting platforms.

Why doesn’t HostGator offer the most current version of PHP that’s compatible with WordPress?

Currently, HostGator does offer the latest version of PHP, however, when new versions of PHP are released there are several reasons why the newest version wouldn’t be immediately available. HostGator’s shared platform is a highly customized environment. At the time of writing, PHP 7.4 is the newest version of PHP that WordPress supports (see current requirements here). And while that version is technically compatible through cPanel on WHM, it requires a newer version of cPanel that could potentially interfere with some of the customized tools that we have on the shared platform. 

We want to make sure that all the changes in newer versions of cPanel get tested before we roll them out, to ensure that there are no major issues for our customers’ sites when we make those cPanel updates. 

Where can I get help with my PHP upgrade?

If you’re having trouble figuring out which version of PHP will work with your version of WordPress, or if you upgraded and then found a problem with your site, there are ways you can get help. 

Because WordPress has built-in error logging, you have access to a record of problems that might come up as you work on your site. The error_log file in your WordPress installation directory will typically show you any PHP errors that are being generated. You may be able to use that information to solve the problem yourself, or you can share it with HostGator’s support team for guidance.

Usually the most common errors that result from upgrading PHP are caused by jumping too far forward. So, if you upgrade to one of the newer versions and start seeing that some of your site features are deprecated, the first step is to roll back to an older version of PHP. 

You can also get in touch with our support team via live chat or phone at 866-96-GATOR to help get your site working the way it should be. With compatible versions of PHP, WordPress and plugins for your site, you’ll get optimal functionality and security.

russell widger

Russell has been with HostGator for 9 years. He specializes in Linux Support and Security.