User

Site Broke After Switching PHP Version

Fix a website that stopped working after changing its PHP version in Opterius.

Last updated 1775606400

After switching a domain to a different PHP version in the Panel, the site returns a white screen, a 502 Bad Gateway, or a PHP error.

How to Roll Back Immediately

If the site needs to be live now, roll back to the previous PHP version first and troubleshoot afterward:

  1. Go to PHP → [your domain] in the Panel.
  2. Switch back to the PHP version that was working before.
  3. Confirm the site loads correctly.

Once the site is stable, you can investigate the cause at your own pace using the steps below.

Step 1: Check the Error Log

The PHP and Nginx error log is the first place to look. In the Panel:

Hosting Mode → Logs → [domain] → error.log

Or on the server (admin access required):

tail -n 50 /home/{username}/{domain}/logs/error.log

The error message will usually tell you exactly what failed:

  • Call to undefined function ... — a PHP extension is missing in the new version
  • Deprecated / Fatal error: Uncaught Error — code uses a function or syntax removed in the new PHP version
  • PHP Fatal error: memory exhaustedmemory_limit in the new version is lower than the old one

Step 2: Missing Extensions

PHP extensions are installed per-version. An extension enabled in PHP 8.1 is not automatically available in PHP 8.3. Check which extensions the site requires (usually documented by the CMS or framework) and enable them:

  1. Go to PHP → [domain] → Extensions.
  2. Find the missing extension and toggle it on.
  3. The PHP-FPM pool reloads automatically.

Common extensions that may need re-enabling: imagick, redis, memcached, gd, soap, intl, zip.

Step 3: Deprecated or Removed Functions

Each PHP major version removes functions that were deprecated in prior versions. If the site was written for PHP 7.x, it may use functions removed in PHP 8.x (e.g. mysql_* functions, each(), certain mbstring aliases).

Check what changed:

  • PHP 8.0 removed: each(), create_function(), old-style Curly string access $str{0}
  • PHP 8.1 deprecated: Passing null to non-nullable params, mysqli procedural functions deprecated
  • PHP 8.2 deprecated: Dynamic properties, utf8_encode() / utf8_decode()
  • PHP 8.3 / 8.4: See php.net/migration83 and php.net/migration84

If the codebase cannot be updated to support the newer PHP version, stay on the version that works.

Step 4: PHP Settings Not Carried Over

Each PHP version has its own php.ini (and per-domain pool config in Opterius). Settings you customized in the old version — memory_limit, upload_max_filesize, max_execution_time, post_max_size — are not automatically copied to the new version.

Re-apply them:

  1. Go to PHP → [domain] → Settings.
  2. Set memory_limit, upload_max_filesize, and any other values the site requires.

Related