DED9

WordPress PHP Versions: Best PHP for WordPress in 2023

In today’s world, having a website as an identifier for the online activities of individuals and companies has become inevitable. But have you ever wondered how to make the most of your website? One of the ways to improve site performance is to use the appropriate version of PHP for WordPress. But for someone who has little familiarity with programming concepts, this may seem a bit complicated. Here, the best solution to this problem is to use a suitable version of PHP for WordPress, which improves the performance and speed of your site.

Since using the latest version of PHP is essential for site optimization and security, we suggest using PHP 8 for WordPress.

If you have tried all the solutions for your site’s speed problem and it didn’t work, try changing the PHP version to the most suitable version for you. But the question that many people have is how do I know that the problem is with PHP, and how do I know the most suitable version of PHP for me? In this article, we will examine this issue, and together, we will discuss how to experience a significant improvement in the performance and speed of our website by choosing the correct version of PHP. But before that, consider a suitable server for your site’s infrastructure.

You can visit our virtual server purchase page and choose the most suitable plan among our different methods and different locations of our servers.

WordPress PHP Versions: Best PHP for WordPress in 2023

Learn about supported PHP versions.

New versions of PHP are released regularly. In addition to other functional and performance improvements, these updates usually include bug fixes and security improvements. Each version of PHP is usable for three years from the time of release. The support period for each PHP version includes two main support phases:

Two years of active support: Support includes fixing bugs and security issues during this period.
One year of security support: Support only includes fixing critical security issues during this period.

After three years of the support period, the version reaches its end of life (EOL) and is no longer supported. Using an unsupported version of PHP is not recommended at all; it may expose security vulnerabilities and software bugs.
Current WordPress PHP versions

The official PHP website maintains a unique page for checking the status of supported versions. Therefore, the current PHP versions that can be safely used for WordPress are:

When an older PHP programming language is deprecated, it is removed from the list, and a new version with full support is usually added.

PHP requirements in WordPress

WordPress generally has specific server requirements, including PHP requirements, hosting details, and other software dependencies.

Technically, each version of WordPress is compatible with specific versions of PHP. However, although the software may work with older versions of PHP that have reached end-of-life, the platform recommends using only supported versions of PHP.

Note: The compatible PHP version is the version that WordPress needs to work correctly, regardless of whether it is still supported or not.

Here is a list of compatible PHP versions for each WordPress version, keeping in mind that we only consider WP versions that can work with currently supported PHP versions:

Minimum PHP version of WordPress

Each version of WordPress requires a specific minimum version of PHP. However, WordPress recommends using at least a supported version of PHP, regardless of your WordPress installation.

The minimum WordPress PHP version is PHP 8.0.

Minimum WordPress PHP version (unsupported): PHP 5.6.20+ (this version is no longer supported and may expose your site to severe vulnerabilities and bugs)

We advise you not to use it if the minimum PHP version is not supported, even if it is compatible with your website’s version of WordPress.

For this reason, here we also mention the minimum PHP requirements for each WordPress installation version. However, you should know that we only cover WordPress compatible with supported PHP versions.

What is the recommended PHP version for WordPress?

To install and use WordPress, you need specific versions of PHP. The recommended WordPress PHP version depends on the WordPress version you are using. The recommended version for WordPress PHP is the latest supported version compatible with your website’s version of WordPress.

What is the latest version of PHP for WordPress?

PHP is constantly working to update its framework and fix bugs and security issues. WordPress plans to support new PHP versions as they are released. The latest PHP version currently supported by WordPress is PHP 8.2 and is supported by WP 6.1.

However, WordPress compatibility with PHP 8. x is still in beta support. However, most of the WordPress functions will work, but sometimes you may face some minor problems.

Some plugins and skins are not yet compatible with PHP 8. x. Therefore, checking the compatibility of your plugins and skisecs is recommended before updating to new PHP versions.
How to check the WordPress PHP version?

This section discusses checking the PHP version used in a website with a WordPress content management system. To check the PHP version used on the website, follow these steps:

Here, you will see your website’s PHP version and other server details.

 

What’s the point of keeping your PHP version up to date?

One of the most important things you should do as a site administrator is to keep your PHP version up to date. But why should we do this, and what advantages can this work have?

Maintain and increase security.

The first important reason to update PHP is security. Updating your PHP system will be more secure and protected from hacking attacks and future damage. Versions before PHP 7.4 no longer receive security updates and are, therefore, vulnerable to attacks.

Like other major systems, PHP is constantly being updated and developed, and each new version that is released has a wide range of changes implemented to increase security and solve problems, which is why we recommend always be aware of PHP updates and updating them regularly.

Improving Performance

With the release of new versions of PHP, the performance of this language has improved significantly. PHP is a critical and colossal programming language that should constantly be updated to always take precedence over your other platform optimizations and updates. With PHP 7 installed, your system can execute requests twice as fast per second, almost half as quickly as previous versions. According to benchmark tests, PHP 7.3 runs nearly three times more requests per second than PHP 5.6 and is 9% faster than PHP 7.2 on average. Also, according to the chart provided by Christian Vigh, PHP 5.2 is about 400% slower than PHP 7.

Providing the latest features to developers

Each update brings many changes and provides users with different features. For example, version 7 is very different from previous versions, making programming faster, better,, and safer. Also, extensions and plugins are more compatible with newer versions of PHP and are written to more recent versions of PHP.

Changes that happen in new versions of PHP include:

Support

Here we talk about two types of support for the PHP language. Security support only includes updates that are released to fix reported security issues. But the primary support includes updating the PHP version and adding new features. Each license for the PHP language has a specific duration and can be used as long as the update is active. So if you are using PHP language, try to use a version that receives new updates.

Standardization of plugins

When you change the PHP version of your site, the plugins will be unified and better editable. Also, connecting to newer plugins is easily possible.
Providing the possibility of using new capabilities and features

Changing the PHP version of the site allows you to use better and unique features of this programming language.

increasing speed

Changing the PHP version of the site increases the speed of different platforms. For example, in the Drupal content management system, by changing the site’s PHP version to version 7 or higher, the site’s speed increases by 75%, and this positive effect in the framework also reaches 95% for processing speed in one second.

 

According to the mentioned benefits, changing the PHP version of the site is done for necessary and sufficient reasons. But you should pay attention to the fact that how these changes are made is essential.

Check the PHP version of the server using the file

You can upload your file to the server and check your PHP version using FTP, DirectAdmin, and cPanel services.

Create a new file

To do this, you must create a new file called phpInfo.php on your system. Then, using Notepad, open it, put the following code in it, and save the file.

<?php echo 'Current PHP version: ' . phpversion() ; ?>

This PHP command will return the version of PHP currently installed on your system.

file upload

In the second step, you need to place the created file in the main root of your server and the public_html folder.

Run the file

In the third step, by going to your file path, visit domain.com/phpinfo.php, and if everything is done correctly, you will see your PHP version.

To check the version of PHP installed on Windows, Mac, and Linux systems, you can use Command Prompt or Terminal. On Windows, by opening cmd, and on Linux and Mac, by opening the terminal, enter the following code to check the version of PHP installed on your system.

php –v

How to check the PHP version in WordPress?

If you use WordPress version 5 or higher, you can easily see your PHP version in the “Site Health” section. If you are using older versions of WordPress, you can still access your version of PHP using the method described above. Simply put, the performance of PHP you are using is available on the WordPress system.

How to check the PHP version in Direct Admin

If you use versions 1.431 and later of DirectAdmin, you can install two different versions of PHP on your server, and each user can choose the desired version for each domain.

If you are using the old DirectAdmin user interface, follow these steps to change the PHP version in your domain:

If you are using the new DirectAdmin user interface, follow these steps to view the PHP version:

1. Log in to DirectAdmin.

2. Select the CustomBuild option from the Extra Features menu.

3. Select the Edit Options tab and see the PHP version you want.

You can also view the PHP version using the Command Line of the DirectAdmin server:

Log in to the DirectAdmin server.
Run the following command in the command line of the server:

 

# /usr/local/DirectAdmin/custombuild/build options | grep PHP

The output will be shown to you below:

[root@web ~]# /usr/local/DirectAdmin/custombuild/build options | grep PHP PHP (default): 7.4 as php-fpm PHP (additional): 8.0 as php-fpm PHP (additional, 3rd): 7.0 as php-fpm PHP (additional, 4th): 7.2 as php-fpm [root@web ~] #

How to check the PHP version in cPanel

You can also see the PHP version in cPanel. To see the PHP version in cPanel, you must follow the steps below:

Choosing the best PHP version

The best version of PHP is the latest version of PHP. In other words, the best way is to choose the new version of PHP. By updating the PHP version, you will benefit from more security, efficiency, and features. Currently, the latest version of PHP, version 8, is the best option, and any performance for which a security update is available is refined. It is not recommended to use PHP versions older than 5; Because it does not have the necessary efficiency and security and needs to be updated to new versions as soon as possible. Also, developers are responsible for updating PHP, and old code must be updated to be compatible with more recent versions of PHP if needed.

How to change the PHP version of the site

Depending on your platforms, there are different ways to update the PHP version. PHP is an open-source language that you can run and use on different systems. Next, we will check how to update PHP on other platforms:

How to change the PHP version in cPanel

To update the PHP version in cPanel, log into your server’s cPanel page. Then in the Software section, if the MultiPHP Manager option is available, use it to change the PHP version. If the PHP Selector option is open, you should use it to change the PHP version. It is straightforward and does not require special technical knowledge.

How to change the PHP version in MultiPHP Manager

Please follow these steps to upgrade the PHP version of a specific domain:

1. Select the MultiPHP Manager option from the Software section.

2. Choose the domain you want.

3. Select the desired PHP version and click on the Apply button.

How to change the PHP version in PHP Selector

To change the PHP version of your site, you must go to the Software section and select the PHP Selector option. After that, you have to choose public_html and the directory of the site that you want to change the PHP version of.

In this step, select the version you want from the drop-down menu and click on the upgrade option. If you use this method to upgrade your PHP version, all the folders and files inside your selected folder will use the defined PHP version.

How to change the PHP version in Direct Admin

Changing the PHP version in Direct Admin is not a complicated task, and you can easily change the PHP version in Direct Admin with a few steps.

1. First, enter the DirectAdmin control panel as your user.

 

 

2. Find the PHP Version option below the Real-time Resource Usage (Disk, Bandwidth, Email) panel.

 

3. To change the PHP version →, click on Change.

 

4. Select the PHP version from the drop-down menu → click on SAVE.

 

4. Congratulations! You have successfully changed the PHP version in Direct Admin.

Requirements for using multiple versions of PHP in Direct Admin

You can install up to 4 versions of PHP on Direct Admin. If you have decided to use several versions of PHP simultaneously, then you must activate php_version_selector in your direct admin. If you don’t know if this feature is active in your direct admin or not, you can find out by running the following code:

/usr/local/DirectAdmin/DirectAdmin config | grep php_version_selector

 

 

If you use this code and find that php_version_selector is disabled, you can use the following code to enable it:

 

/usr/local/DirectAdmin/DirectAdmin set php_version_selector ۱ restart

 

Use a different PHP version for the subdomain.

You can install a specific version of PHP for a subdomain. To do this, there are two methods in front of you: one through the graphic panel and the other through the command line.

To set the PHP version through the DirectAdmin graphical panel, you must apply settings in the DirectAdmin.conf file and have at least two versions of PHP installed on the system. Follow the steps below to do this:

  1. Log in to DirectAdmin.
  2. Select Sub-Domains Setup.
  3. Select Document Root Override.
  4. For each subdomain, select the desired version. To set the PHP version via computer, you can follow these steps: Enter the corresponding directory:
/usr/local/DirectAdmin/data/users/USERNAME/domains/DOMAIN.COM.subdomains.docroot.override

 

In CustomBuild options.conf depending on your settings, use:

php1_select=1-5

 

We give an example for a better explanation; If you change the php1_select setting to 2, the php2_release and php2_mode settings for the corresponding subdomain will be used. In the file below, each subdomain is on a separate line.

domain.com.subdomains.docroot.override

If your subdomain is sub.domain.com, you can do the following:

sub=php1_select=۲

Each different domain path, a different PHP version

This is possible if you want to use different PHP versions for each path and domain. Of course, you should check whether your mod_php has this possibility. For this, you need to enter the custom build.conf file in DirectAdmin and follow the steps below:

mod_php

mod_php settings usually are in default mode. You can use the following two methods to change this section:

Open the htaccess file in the public_html folder and add the commands php_admin_flag / php_admin_value.
Enter the main admin level, open Custom Httpd Config, and add php_admin_flag / php_admin_value commands.

php-fpm

php-fpm allows you to choose multiple php versions for different domains and paths. Using PHP-fpm, users can manually determine the PHP version through their panel. Because php-fpm is located on their independent server.

fastcgi

One of the other methods that can make this feature possible for you is the fastcgi method. To do this, just create an .ini file manually at /usr/local/directadmin/data/users/username/php/domain.com.ini for fastcgi to read.

Using the plugin to manage and update the PHP version in Direct Admin from within the panel

There is a small program for managing and updating the PHP version in DirectAdmin that you can use from within your DirectAdmin.

How to change the php version in plesk server

If you use plesk and want to change the php version on the plesk server, follow the steps below step by step with us:

Picture

To get started, you need to log in to your server and after entering the website and domain section, click on the PHP settings option. Below this option, the PHP version of your site will be displayed, and by clicking on the corresponding option, you will access the PHP version change section.

Using the corresponding box allows you to easily change the PHP version of your site without any problems.

Of course, you may not have your site online yet and use a local server to run the site. In this case, you can easily change your PHP version on the local server using the relevant settings.

How to change PHP version in xampp

You can install WordPress on your computer with a program called Zamp. Using this program, you can create a virtual server for your site on which WordPress runs. If you want, you can also change the PHP version of this program. This is very simple and you don’t even need special expertise. Be with us to tell you how you can change the PHP version of Zamp on your computer.

Picture

Zamp software is a program that provides an environment similar to the image shown above. To install and activate WordPress, you need to enable the first two options on your local server. Also, to change the PHP version in this software, you must click on the “config” option.

Picture

After the previously mentioned item, you need to click on the Apache option (httpd-xampp.conf) to open a file containing a series of codes. In this file, you should look for a specific piece of code as follows.

LoadFile "c:/xampp/php/libpq.dll"
 
LoadModule php5_module “c:/xampp/php/php5apache2_4.dll”
 
LoadFile “c:/xampp/php/php5ts.dll”
 
LoadFile "c:/xampp/php/libpq.dll"
 
LoadModule php5_module “D:/xampp/php/php5apache2_4.dll”

After you find this code snippet, what you need to do is replace it with the code below to upgrade your PHP version to version 7.

 

LoadFile "D:/xampp/php/php7ts.dll"
 
LoadFile "D:/xampp/php/libpq.dll"
 
LoadModule php7_module "D:/xampp/php/php7apache2_4.dll"
 
LoadFile "D:/xampp/php/php7ts.dll"
 
LoadFile "D:/xampp/php/libpq.dll"
 
LoadModule php7_module "D:/xampp/php/php7apache2_4.dll"

 

Conclusion

Choosing the right version of PHP for WordPress can help web designers to improve the performance of their site by taking advantage of new PHP features. Due to the increase in speed, standardization of plugins and the ability to use new technologies, changing the PHP version of the site is one of the effective ways to optimize the site and improve its performance. As a web designer, this is an important choice for you and should be done carefully and with sufficient knowledge.

If you have any questions in this regard, you can ask us in the comments section. We will answer your questions as soon as possible.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exit mobile version