How to Change Default PHP Version in cPanel

Updated on Feb 14, 2022

Having the option to choose from multiple PHP versions is an absolute must. That’s why FastComet supports multiple PHP versions on every shared hosting package. 

FastComet uses AlmaLinux as the OS on our servers to improve server stability. A major feature of AlmaLinux is that each cPanel account can select the global PHP version they want to have for their websites. You have the option to change your PHP version and enable/disable different PHP modules via the web-based interface in your cPanel. 

Our SysAdmins install the most recent versions of PHP on our shared hosting servers after extensive testing and troubleshooting. Keep in mind that the default version of PHP for a newly created website is usually one or two versions behind the latest update. That’s for the sake of stability. However, feel free to update to the latest version as soon as it is available.

PHP End of Life

At some point, a version of PHP will become obsolete which is referred to as the “end of life” of that version. This means that the version of PHP will no longer receive any security fixes. Unfortunately, there are many websites that still run on outdated PHP versions. All these websites are at risk.

Use an Up-to-date PHP Version

There are several very solid reasons why you should use one of the most recent PHP versions:

Better Security

The primary reason that you should update your PHP is for security. Older PHP versions are no longer getting security fixes. That means known vulnerabilities are not being fixed on that version which leaves your site open to attacks.

Site Speed

Newer PHP versions always execute code faster which means faster page load speeds. Furthermore, faster page load speed leads to a better user experience and good SEO signals. You should know that site speed is an SEO ranking factor. So if you are aiming for page one of Google search results, site speed is quite important.

Ongoing Support

When running the latest PHP versions, you are protected from the latest known vulnerabilities. Developers work to fix security vulnerabilities in PHP when they come to light. The same goes for known bugs.

How to Check Your PHP Information

Now you’re curious how to update your PHP version. First off, you have to find out what version of PHP you are using. There are several ways to check your PHP version.

How to Check PHP Information via the WordPress Site Health Page

When using WordPress, you can access the Site Health page from your WordPress Dashboard and see lots of useful information that you can address to keep your site secure. You can reach it by going to Tools and then clicking on “Site Health”. Another way is to just append your domain with:

/wp-admin/site-health.php

With Site Health, you can see the exact PHP version your website is using at the moment.

How to Check PHP Information Using cPanel

You can easily check your PHP information using the Select PHP Version cPanel tool:

Select PHP Version in cPanel

You will then be forwarded to a page with detailed information about your current PHP version, modules, values, etc. Scroll down to browse for more.

If you wish to find data about a specific module or function, you can use the CTRL + F (CMD + F for macOS) shortcut to open the search feature within your browser.

How to Check PHP Information by Creating a phpinfo File

In case your hosting platform doesn’t offer the mentioned built-in PHP Info feature, there is no need to worry! You can reach the same goal by creating a phpinfo file in your public_html directory.

The file will be accessible via a browser and will show you the same detailed information.

You will need a way to access your public_html files. Here we’re using the cPanel File Manager as an example.

  • Navigate to File Manager under the Files section in your cPanel:

Find File Manager cPanel

  • Once you’re in the public_html directory, click the New File button:

Create New File

  • Name your file phpinfo.php and press Create:

Create PHP Info

  • Scroll down and locate the new phpinfo file within the directory, then right-click to Edit:

Edit phpinfo File

  • Copy and paste the following code into the text editor and press Save:
<?php
phpinfo();
?>

The same result can be achieved by using any text editor on your computer. Create the phpinfo.php file by following the same steps from before, then uploading the file to your server’s public_html folder through an FTP client.

If you don’t know how to configure or never worked with an FTP client, such as FileZilla, refer to our FTP guide for more information.

How to Check PHP Information Using a Browser

You should have a phpinfo.php file in your public_html directory by now. So, all that’s left is to access the file by adding /phpinfo.php at the end of your domain name.

You should see a similar view when the file is accessed via any browser:

phpinfo View

Note: If you don’t want your phpinfo page to be displayed all the time, you can easily disable the file by giving it a different name. phpinfo.php_disabled, for instance.

How to Change Your PHP Version

To change your PHP version:

  • Log into your cPanel and refer to the Software section and click on the Select PHP Version icon:

Select PHP Version cPanel

  • Via the cPanel PHP Selector interface drop-down menu, you can see all the available PHP versions:

Choose PHP Version from Drop Down

  • To change the current version of your hosting account simply select the desired version and click on Set as Current. This will reload the page and give you the option to enable or disable different PHP modules available for the desired PHP version:

Set PHP Version as Current

  • We have a default PHP modules configuration that you can load by using the Reset to Default button and getting a green message box that indicates success. You can also select your custom configuration which will be saved automatically after each time you add or remove a checkmark:

Reset to Default

  • In addition to the Extensions selector, you can edit your account php.ini file which allows you to apply custom PHP variables for your account. You can perform this via the Options button:

Go to PHP Options

  • Via the PHP settings section, you can modify variables such as the max_execution_time and the memory_limit for your PHP executions:

Set PHP Memory Limit

Additionally, you can easily enable the log_errors and change upload_max_filesize.

How to Change Your PHP Version for Different Websites (Directories)

The answer to that question is yes. However, it’s a bit more complicated than changing the PHP version for your entire account. Luckily, we have a guide that explains everything in detail and you should have no trouble setting different PHP versions per directory.

How to Change PHP Settings

In addition to changing the PHP version from cPanel, you can also change some specific PHP settings. You have the option to enable/disable PHP extensions and configuration directives such as allow_url_fopen, error_log, etc.

If you use this feature, you don’t need to configure and maintain custom php.ini files—you control all PHP settings directly from cPanel.

To change your PHP settings, do the following:

  • Log in to cPanel.
  • In the Software section of the cPanel home screen, click Select PHP Version.

Note:
In case you do not see Select PHP Version in the Software section, contact our technical support via a support ticket.

  • Select the extensions that you want to enable for the current PHP version:
  • If you want to enable an extension, select the check box next to the extension name.
  • If you wish to disable an extension, clear the check box next to the extension name.

Selections are saved automatically.

  • In order to reset the extension list to the default configuration, click Reset to default in the top right corner;
  • To change settings for the current PHP version;
  • Click the Options tab positioned near the top of the page;
  • Click the value next to the setting that you need to modify;
  • Depending on the type of setting, a list box may appear with predefined settings that you can choose. Or, a text box may appear so you can type the value.

Changes are saved automatically and take effect immediately.

Note: After you modify a setting, a Reset to default link will appear beneath the setting label. Click the link if you want to change the setting back to its default value.

Conclusion

Switching to one of the latest PHP versions may not seem like something that important to a lot of users, but it’s actually crucial for the security and speed of your website(s). Use this tutorial and you will have no problem changing your PHP version. Feel free to bookmark it in your browser and come back to it when you need to switch to a newer version of PHP, about which we keep everyone posted in our blog.

On this page...

    cPanel Hosting

    • Free Domain Transfer
    • 24/7 Technical Support
    • Fast SSD Storage
    • Hack-free Protection
    • Free Script Installation
    • Free Website Transfer
    • Free Cloudflare CDN
    • Immediate Activation
    View More