Which PHP Version to Use With WordPress?

PHP is one the most widely-used scripting languages today. Because of its versatility, it has been put to many uses over the years. For example, PHP can be used to manage databases, build entire sites, or manage dynamic content.

Released in 1995 by Rasmus Lerdorf, PHP came out as open source and open for public use and adaptation. Since then it’s undergone significant transformation. Because of this, PHP itself has at times evolved significantly between releases.

What PHP Versions are Compatible With WordPress?

Which PHP Version to Use With WordPress?, What PHP Versions are Compatible With WordPress?
Newer versions of WordPress require more modern iterations of PHP. (Source: DisplayWP)

As with PHP, WordPress itself has evolved over time. Each time applications evolve, their requirements may change. To add to the complexity, not all WordPress users always keep their version current.

Support for PHP in WordPress was first introduced with WordPress version 2.0 – at the time, it was partially compatible with PHP version 4.0. Over time as WordPress advanced, the minimum supported versions of PHP moved forward as well.

For instance, since WordPress version 5.2, it has become mandatory for users to have at 

the minimum of PHP version 7.2.

How to Find out Which PHP Version You’re Using

Thankfully, WordPress was designed for the modern era and helps users handle things more easily. This goes the same for something minor like trying to find out the PHP version that’s currently being used by your WordPress installation.

In fact, there are a number of ways you can do this:

1. From your Control Panel

With most web hosting plans comes access to a control panel that lets you manage your account. Typically, this will either be Plesk or cPanel. Regardless of that, somewhere there will be an option for you to manage web scripting or even PHP directly. Clicking on that will enable you to know what version of PHP your server is currently running.

2. In WordPress

Which PHP Version to Use With WordPress?, 2. In WordPress

By far an easier solution, all you need to do is open your WordPress admin panel. There, go to Tools and click on ‘Site Health’. At the top of the page, select ‘Info’ and scroll down towards ‘Server’. Expanding that option will show you various information about the server your WordPress is hosted on, including the PHP version.

3. Using Command Line Instructions

If for some reason the above two methods are not available (or not preferred) then simply jump into the command line interface for your server. Then, type in ‘php –version’ or ‘php -v’ and you should see the package that you have already installed.

The Advantages of Upgrading Your PHP Version

Under most circumstances, it is always better to keep your applications updated, no matter what you’re using. Earlier, we discussed the fact that as WordPress moves forward, it requires PHP versions that keep up with it. There are a few core reasons for this.

Key advantages of keeping PHP updated include:

Better Performance

Since introduction, each new PHP version has proven to offer much better performance over the last. For example, PHP 7.4 has been noted to boost script loading speeds of between 30-50% on average. This can result in a much faster WordPress site for you.

Improved Security

Almost entirely without fail, newer versions of anything coded come with improved security. Not all of this is always a new development or facet of security. In fact, improved security most of the time refers to patching that has been done to resolve existing vulnerabilities discovered as the application is being used.

New Features

At times, newer versions of PHP come with new features or sometimes, improvements to existing features. This means your site might be able to make use of new functionalities that weren’t possible before. 

Disadvantages of Using an Older PHP Version

As you can see from the advantages, not updating your PHP version can result in you missing out on some things. While being able to accept slower speeds is one thing, ignoring a fix for known vulnerabilities is simply asking for disaster.

Finally, assuming you keep your WordPress updated, there will eventually come a point where it will no longer support the older PHP version you’re on. At that point of time you either have to update PHP or simply stop updating WordPress.

How to Safely Upgrade Your WordPress PHP Version

By nature, WordPress will attempt to use whatever version of PHP you have installed on your web server. That means if you want to update PHP, it’s done on the server, not from inside WordPress.

The best way to achieve this is to make use of your web hosting control panel. There will be an option for you to select the PHP version you want – simply from a dropdown menu. 

Note: Not all web hosts will offer the same versions of PHP. This is especially important to take note of if you need to use any specific version, especially if you’re on a shared hosting plan.

Updating PHP in Plesk

From the control dashboard of the website you want to manage in Plesk, click on the option ‘Hosting Settings’. From there, scroll down to ‘PHP support’ and select the version you want from a dropdown menu. 

Updating PHP in cPanel

In cPanel, scroll down to the ‘Software’ section and look for an option called ‘Select PHP version’. Clicking on that will show you the current PHP version with a small inverted triangle next to it. Select that icon and you can choose from a list of available PHP versions.

Upgrading Your PHP Version with ScalaHosting

Which PHP Version to Use With WordPress?, Upgrading Your PHP Version with ScalaHosting

ScalaHosting makes use of SPanel, an advanced control panel which is highly capable and doesn’t come with the burden of additional licensing fees. It’s simplicity of use can be seen in the PHP selector as well.

All you need to do is login to SPanel and scroll down to ‘Tool’ to select ‘PHP manager’. The next screen will show you the current version of PHP being used. Simply click ‘Change’ to select from a list of available PHP versions.

Updating Your PHP Version Manually on Your Server

If for some reason you want to bypass the control panels and update your PHP from the command line, that’s possible as well. For the following instructions, replace sudo with the appropriate command needed for the particular distribution you’re working on:

  • sudo add-apt-repository ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get install php7.4 php7.4-fpm php7.4-xml php7.4-mysql php7.4-gd

This will install not just PHP but the other extension libraries that it needs as well. Once you’re done, you will need to enable the new module and if necessary, disable the older ones.

In the interest of streamlining, we’re going to look at how to do this only on Apache and Nginx. Before you decide to do this, ensure that you create backup copies of any files that you may be editing in the process.

Nginx

Of the two web servers, Nginx is a bit more complicated to manage than Apache for handling PHP. You will have to work with some configuration files.

Open the configuration file for the PHP-FPM socket:

sudo vim /etc/nginx/sites-available/default

In that configuration file, swap to the new socket:

location ~ \.php$ {

     include snippets/fastcgi-php.conf;

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

}

Save the file and restart Nginx:

sudo service nginx restart

Apache

Disable the PHP versions you no longer need:

sudo a2dismod php7.0

Then enable the new one:

sudo a2enmod php7.4

Restart Apache:

sudo service apache2 restart

Conclusion

Since PHP is such a popular scripting language to use, many applications and control panels have implemented easy ways of working with it. As you can see from the instruction in safely updating your PHP version, it can be as easy as choosing from a dropdown menu.

Manual installations are still relatively easy though, especially for those who are used to the command line interface. Ideally, look over new PHP releases carefully since not all will have the major benefits discussed here.

Frequently Asked Questions

Can you use PHP in WordPress?

Yes, however perhaps not in the general interpretation of the word ‘use’. It is not possible to insert and use PHP code directly in WordPress pages or posts. Instead, they are written as complete scripts and then adopted by the theme you’re working with.

What PHP version does WordPress use?

The latest version of WordPress 5.5 recommends that it be used with PHP version 7.4 or newer. However, it is backwards compatible until version 5.6.2. Earlier PHP versions than that will no longer work with WordPress.

Should I learn PHP for WordPress?

It is entirely unnecessary to learn PHP in order to use WordPress. For most general usage, WordPress users are not required to learn any form of coding. The exception to the rule is for those who wish to create custom scripts for their own site – or even general release.

Will updating PHP break my site?

Updating PHP is typically a safe process and should not have any adverse effects on your site. If you run many plugins with your WordPress site, there may be compatibility issues. In those situations, make sure you attempt an installation on a staging clone for your site first.

How do I install PHP on WordPress?

PHP is installed on the web server and used in WordPress. If you’re using shared hosting, it should come pre-installed and you can select the version from your control panel. For VPS, PHP may or may not come with PHP pre-deployed, depending on your host.

Was this article helpful?

What’s your goal today?

1. Find the right WordPress hosting solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lightning-fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Make your website lighting fast—or your money back
Slow websites lose visitors and sales. See how you can surf tsunami sized traffic spikes—or any traffic—with ease with ScalaHosting. Fill out the form, and we’ll be in touch!
Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.

Photo

Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain