The PHP programming language is known as one of the most important programming languages currently available, and it is relied upon to develop a large number of websites and web applications, and WordPress is no exception to this, as a large part of WordPress has been programmed based on that language, and this includes the core of the program. itself.
A large number of website owners rely on old versions of PHP in WordPress at the present time, and this poses a great danger to the site, since not updating PHP continuously may make the site easier to hack, and this is on the one hand, and on the other hand, relying on an old version of PHP may make the site slower to load and less stable. Therefore, in this article, we explain how to update PHP to the latest version of PHP, in addition to discussing the most important reasons why you should do so.
What you need to know about PHP
As previously mentioned, PHP is a programming language that is relied upon to build web applications, including WordPress. When looking at the files of any WordPress website, one can easily notice the amount of PHP files used, including the famous WP-Confing.php file.
Accordingly, the PHP programming language actually works to form a large part of the main core of the WordPress program and the websites that are created based on it, and templates, plugins and tools dedicated to WordPress work based on this language.
WordPress supports a wide range of PHP versions without a problem, but continuing to rely on older versions may negatively affect the performance and security of the site.
Read also: How to add PHP code to your WordPress site without modifying the source code
PHP versions and how often they are updated in WordPress
One of the basic rules that must be followed when building a website based on WordPress is constant updating, which includes updating the version of WordPress itself, updating templates, and updating plugins and tools.
PHP is no exception to this, as it must be updated periodically, and it is recommended to use the latest available version without preferring any older version, while each version of PHP is supported for two full years.
After the end of the support period, an additional year of support is provided for the same version, but this last year includes only high-risk security updates. WordPress currently recommends, as of July 2021, PHP version 7.4 or later, with the latest version currently being PHP 8.0.
As an example, PHP 7.2 was released in November 2017, and based on the aforementioned rule, support for this version stopped in November 2019, and even security updates stopped in November 2020. Despite this, a percentage of up to 37.2% of WordPress sites are still running on this version.
Although hosting companies usually provide automatic updates for the PHP programming language on their servers, some companies do not do this, especially if they provide their services for a small fee. This is because the process of updating PHP requires a great effort on the part of the companies, in addition to the need to provide technical support to customers afterward. Update.
Read also: How does WordPress work, and what are its components? A comprehensive explanation for beginners
The importance of updating PHP on your WordPress site
By reaching this part of the article, you are now aware of what the PHP programming language is and its utmost importance in relation to the WordPress program and its uses. Perhaps you also have a brief idea about the importance and necessity of updating PHP, but this does not prevent talking about some of the advantages that the user gets only by updating PHP on his site.
Improve site speed
One of the advantages that a website administrator notices once PHP is updated is the improvement in website loading speed. According to tests conducted by Kinsta based on seven different versions of WordPress, the results were excellent:
From the previous table, you can notice a clear difference in the improvement in the speed of the site, that is, the number of requests per second (Requests Per Second), simply because the newer version of PHP requires less time to fulfill the same number of requests.
A big difference also appeared in the latest version of PHP, which was subjected to the same tests, and it shows us that the latest version 8.0 offers an improvement of close to 50% compared to version 5.6, which websites are still using to this day.
Read also: The most important procedures to increase the speed of your WordPress site Comprehensive guide
Security and protection from vulnerabilities
We constantly update WordPress to the latest available version, because the latest version offers greater levels of security and protection from the vulnerabilities that were discovered and on the basis of which the update was issued.
This concept applies to the WordPress core itself, to templates, plugins, and any other software, and it also applies to PHP! This is because every new version of the PHP programming language provides solutions to problems and security vulnerabilities that have appeared in recent times.
Updating PHP protects the user and his site from various vulnerabilities and practices such as SQL injection or even DoS attacks, etc. Indeed, during the year 2021, only two vulnerabilities were discovered in PHP, compared to 14 vulnerabilities in 2020, 23 vulnerabilities in 2018, and 108 vulnerabilities in 2016.
Read also: Secure and protect WordPress websites from all vulnerabilities | Comprehensive guide
Save expenses
Updating the PHP on your site won’t be difficult, especially when you follow the steps below, but it will protect you in the future from any expenses necessary to fix any problems that occur due to not updating PHP.
For example, if your site was hacked due to exploiting a vulnerability in an old version of PHP, it may cost you large sums of money to restore your site to its original state and secure it again.
How to know the current PHP version on your WordPress site
WordPress allows you to know which version of PHP is used to run your site in simple steps. There is no doubt that knowing the version of PHP currently installed on your site is an essential step that must be taken before trying to update PHP.
You can find out the version of PHP on your site by following these steps:
1- Go to your site’s control panel by typing /wp-admin directly after the site link or through the hosting control panel depending on the settings you use.
2- Log in to the control panel, go to the “Tools” section, and through it go to the “Site Health” section, as in the following image:
3- When you click on “Site Health,” you will be taken to the page dedicated to displaying the site’s health status, which includes a number of sections, including “Recommended Improvements.” If your version of PHP needs to be updated, you will find a notification in this box. In our case, PHP is up to date and therefore it appears under the “No problem was detected” box, as in the picture:
4- Through the same page, you can also go to the “Information” section, which appears at the top next to the “Status” box, and through it you can go to the server settings and all the related settings will appear.
As you can conclude, if your site’s PHP version is lower than 7.4, which is the minimum recommended by WordPress, then it is time to update it, which we explain in the next part of the article.
Pre-update PHP on your WordPress site
From all the previous points, we reached a main conclusion, which is that updating PHP is essential for the proper functioning of your WordPress site, and for its security and stability as well. What is distinctive is that updating PHP is very easy, and it is a skill that will definitely benefit you, but it consists of a number of steps that must be accomplished. correctly to avoid errors.
Since the process may include some errors, or incompatibility problems may occur due to updating PHP, the first and essential step is to create a copy of your site so that you can start experimenting with it.
The process is done by creating an exact copy of your site that needs to be updated, and then the update is performed on the created copy, so you can try the process on the side site first.
How to create a copy of your site
Any WordPress website consists of two basic parts: the site files and the database. Therefore, you can create an exact copy of your site just by creating a copy of the database on the one hand, and a copy of the site files on the other hand.
Some hosting companies provide the possibility of creating a copy of the site in an integrated form within the options. In this case, the copy that will be created from the site will be a live copy, but this is not the best option.
This is because the best option is to create a local copy of your site based on your personal computer, through the XAMPP application, which allows you to create an integrated environment to run websites and web applications locally on your personal computer, with access to database settings as well. XAMPP is characterized by the fact that it automatically relies on the latest available version of PHP.
Learn the details: What is XAMPP and how to install and use it
As previously mentioned, the means through which a copy of a WordPress website can be created vary, but the concept is the same, which is transferring files and databases. To accomplish this process, you can rely on the free Duplicator add-on .
Within the article “How to make a clone of your WordPress site” for the purpose of testing it on WordPress in Arabic, you can learn the correct way to create a complete copy of your site.
Start testing a WordPress update
By relying on both the XAMPP application and the Dulpicator add-on, you can create a complete copy of your site on the PC, as mentioned above. Although this step is optional, it is extremely important, unless you want to risk having your site stop working if any problems occur.
At this stage, you are in the process of updating PHP on the test site, so you must pay attention to any problem or defect that may occur. Here we refer to the Error Log Monitor and WP_DEBUG plugins . These plugins help track and automatically record any errors or problems that occur during the experiment.
Now, within the created experimental environment, you must download the PHP Compatibility Checker add-on , which simply determines the compatibility of the add-ons and templates installed on your site with the latest versions of PHP.
To use these plugins, you must activate the debugging options. You can do this by going to the WordPress files on the site, then going to the WP-Config.php file and starting to edit it.
Within the file, add the following code, modifying false to true for activation. If it already exists, just change false to true.
Final steps
You may now understand that we created the test site locally for one purpose only, which is to ensure that updating PHP on your WordPress site live will not cause any problems, and if your tests did not show any problems or negative results, you are now ready to update PHP directly.
Before updating PHP on your WordPress site
The process of updating PHP depends on the hosting company you are dealing with, or the company operating your server if you have one. Therefore, the steps for updating PHP differ from one hosting company to another, but the basics remain the same.
Below we take a look at how to update PHP within a group of the most prominent hosting companies. Note that you can always contact the customer service of the company you are dealing with for more details or even to have them do the work for you.
Updating PHP within Bluehost hosting
1- Go to your control panel
2- Within the right menu, go to Advanced options
3- From the Advanced Options section, go to the PHP programming language control options, which appear under the name MultiPHP Manager, as shown in the previous image.
4- Later, you can simply choose your site from the list of sites that will appear to you, if you own more than one site, and then choose the version of PHP that you want to use on this site, and then click on Apply for the application.
Read also: The best reliable hosting company and 12 criteria for choosing the best hosting
Updating PHP within SiteGround hosting
1- Log in to the hosting control panel
2- Go to the Websites box, which includes the websites you own
3- You will find in front of you all the sites that you own, along with options for each of them under the name Site Tools.
4- When you click on Site Tools, you will have to go to the PHP Manager within the DEVs list, as in the following image:
5- A pop-up window will appear for you containing the different versions of PHP for you to choose from which suits you, and of course we will choose the latest version.
Updating PHP within HostGator hosting
1- Log in to your hosting control panel
2- Through the side menu, go to the Hosting options
3- Through it, go to the cPanel settings, which you will find visible directly below your site link
4- Within the cPanel settings, go to the MultiPHP Manager options to update PHP In the same way that was explained previously when we talked about Bluehost hosting, which also applies to any other hosting.
You can see the official WordPress guide on how to update PHP for each host separately (in English)
Read also: How to update your WordPress website safely without causing any problems with the website
With this, we have learned the importance of updating PHP for any WordPress site, and the positive impact of doing this process. We also learned the importance of testing these options on an external environment before applying them directly to your site.
Leave a Reply