Skip to content
Web Hosting

How to Upgrade the PHP Version on cPanel Without Breaking Your Site

In this article12 sections

Running an old PHP version is one of the most common ways a site ends up vulnerable. A release that has reached the end of its support stops receiving security fixes, so every flaw found afterwards stays open on your site. The upgrade itself on cPanel takes a minute. The risk is not the click, it is what happens to your theme, your plugins and your custom code on the new version. This guide shows how to upgrade PHP on a cPanel account the careful way: check what you run now, test on a copy, change the version per domain, enable the right extensions, watch the logs, and roll back in seconds if something breaks.

On Siteharbour’s cPanel hosting plans, PHP versions up to 8.4 are available and you choose the version per domain, so you can move one site at a time and keep the others where they are. The same steps apply on any cPanel host that offers MultiPHP.

What you control on cPanel, and what you do not

On shared cPanel hosting, the host installs the PHP versions and keeps them patched. You choose which version each domain uses, and you adjust the settings and extensions that the host allows. You do not compile PHP or edit server-wide files. That limit is useful: you cannot break the server, and a mistake affects one domain, which you can switch back.

Two tools matter. MultiPHP Manager sets the version and the handler for each domain. MultiPHP INI Editor sets values such as the memory limit and upload size for the chosen version. On accounts that use CloudLinux, a Select PHP Version page does both jobs and also lets you switch individual extensions on and off.

Before you start

  • Take a full backup. A restorable copy is the real safety net. The steps are in how to back up and restore a cPanel account.
  • Know what you run today. Note the current PHP version for every domain and subdomain, because each can differ.
  • Check compatibility. Read how to check your code for PHP compatibility before you upgrade, because most failures are known and findable in advance.
  • Pick a quiet hour. Not the middle of a sale or a campaign.

Step 1: See the current PHP version for each domain

In cPanel, open MultiPHP Manager under Software. The page lists every domain and subdomain with its PHP version. Write the list down. A forgotten subdomain on an old version is a common leftover after an upgrade, and it is the one an attacker finds first.

The web version and the command-line version are separate. Cron jobs, WP-CLI and Composer use the command-line one. Check it over SSH:

php -v
ls /opt/cpanel | grep ea-php

Expected: the CLI version, and a list of installed versions such as ea-php82, ea-php83 and ea-php84. If the CLI version is older than the web version, jobs run on the old PHP until you call the new binary by its full path, such as /opt/cpanel/ea-php84/root/usr/bin/php.

Step 2: Test on a copy first

Create a subdomain such as test.example.com, copy the site files and the database into it, and update the copy’s configuration to use the copied database. The subdomain steps are in how to add a subdomain and point it to a folder in cPanel. Set only the test subdomain to the new PHP version, as in Step 3, and click through the site. Turn on error display on the copy only, and read every notice. A site that shows nothing on the test copy is far less likely to fail on the live one.

Keep the test copy private. Add a password to the folder or block search engines, so a half-working copy does not appear in search results.

Step 3: Change the version for one domain

In MultiPHP Manager, tick the box beside the domain you want to change. In the PHP Version list on the right, choose the new version, for example PHP 8.4 (ea-php84), and select Apply. cPanel updates the domain at once, and writes a handler block in the domain’s .htaccess file between lines that say cPanel-generated handler.

Do not edit or delete that block by hand. If you copy an .htaccess file from another server, remove any such block from it first, because it points at a PHP version that may not exist on this account and returns a 500 error.

Check the handler column too. PHP-FPM is the better choice on current cPanel: each account gets its own pool, memory use is lower and the site can handle more simultaneous visitors. If the handler is an older option, read how to choose the right PHP version and handler in cPanel before you change it.

Step 4: Set the extensions and the limits

A new PHP version starts with its own set of extensions, which may differ from the old one. Missing extensions cause errors such as Call to undefined function mysqli_connect() or an image upload that fails. In Select PHP Version, or in the extensions tab of the PHP settings, make sure these are on for the new version if your site uses them: mysqli, pdo_mysql, curl, mbstring, xml, zip, gd, intl, opcache, and imagick if your image plugin needs it.

Then open MultiPHP INI Editor, choose the domain, and check the values. Limits do not carry over between versions in every case. Compare these with the old version: memory_limit, upload_max_filesize, post_max_size, max_execution_time and max_input_vars. A site that worked yesterday and now fails on large uploads has usually lost one of these.

Step 5: Confirm the version really changed

Do not trust the settings page alone. Create a file called version-check.php in the site’s folder with one line, open it in a browser, and delete it straight away:

<?php echo PHP_VERSION;

Expected: the new version number, such as 8.4.x. Delete the file after the check. A file that prints the version, or the output of phpinfo(), tells every visitor exactly what you run, which helps an attacker.

Step 6: Watch the logs for two days

Open Metrics > Errors in cPanel after the change, and again after a few hours, and again the next day. Look for lines that say Deprecated, Warning or Fatal error. Deprecation notices do not break the site today, but they show what will break in a future version, so fix the ones in your own code. Test the pages that matter most: the home page, a post, the login, a form and, for a shop, the cart and checkout.

If the error log shows a fatal error that you cannot fix quickly, go straight to the rollback in Step 7. The errors you are likely to see, and their fixes, are in how to fix common errors after a PHP upgrade.

Step 7: Roll back in seconds

Open MultiPHP Manager, tick the domain, choose the previous version and select Apply. The change is immediate and needs no restart. Because the rollback is this fast, it is reasonable to upgrade one domain at a time during working hours. A rollback does not undo database changes, so if the new version ran an update script that changed the database, restore the database from your backup as well.

Step 8: Update the places that still use the old version

  • Cron jobs. Replace the PHP path with the new binary, as described in how to set up cron jobs in cPanel.
  • WP-CLI and Composer. Call them with the new binary, or they run on the old PHP.
  • Subdomains and addon domains. Each has its own setting, so repeat the steps for each one.

Common mistakes

  • Skipping the test copy. Production is the wrong place to find a fatal error.
  • Jumping several major versions at once. Move one version at a time, testing between each step.
  • Forgetting the command-line version. Cron and WP-CLI keep using the old one.
  • Editing the generated handler block. Let cPanel manage it.
  • Leaving a version-check file on the server. Delete it immediately.

Frequently asked questions

Will upgrading PHP make my site faster?

Usually, yes. Each recent version is faster than the one before for typical WordPress and Laravel code, and PHP-FPM with OPcache helps more. Measure your own pages, because plugins and the database often matter more than the PHP version.

Can I use different PHP versions for different sites on one account?

Yes. MultiPHP Manager sets the version per domain and per subdomain, so you can move sites one at a time.

What if my host does not offer the version I need?

Ask the host to install it, or move to a plan that offers it. For a version the host will not provide, a VPS gives you full control over what runs.

Is a minor update, such as 8.4.1 to 8.4.5, handled by me?

No. The host patches minor releases. You only choose the major version, such as 8.3 or 8.4.

Upgrading PHP on cPanel is a one-minute change surrounded by careful checks. Record the versions you run, back up, test on a copy, change one domain at a time, set the extensions and limits, confirm the version, and watch the log for two days. Keep the rollback in mind, because it takes seconds. For the other platforms, read how to upgrade PHP on Plesk next.

Want this done for you? If you would rather have an engineer plan and carry out the work on your own site, you can hire the author through the Upwork profile of Munaf Sheikh.

Share this guide