Guide

Change the PHP version of a Magento 2 store, safely.

Check that the store and its extensions accept the new PHP version, point nginx and the command line to it, rebuild, and test before anyone notices. Checked on Nov 5, 2026.

Step 1Check

Check which PHP versions your Magento supports

Each Magento release supports two PHP versions: 8.3 and 8.4 for 2.4.8, 8.2 and 8.3 for 2.4.7. See the requirements guide for the full table.

On your server

bin/magento --version
php -v

Step 2Check

Ask Composer if the extensions agree

Composer tells you which packages would block the new version, before you change anything on the server.

On your server

composer why-not php 8.3
composer check-platform-reqs

No output from why-not means nothing in composer.lock blocks PHP 8.3.

Step 3Switch

Point nginx to the new PHP-FPM

nginx passes PHP requests to a PHP-FPM socket. Change it to the new version's socket, test the configuration and reload. The path below is the one Debian and Ubuntu use.

nginx

# in the store's nginx server block
fastcgi_pass unix:/run/php/php8.3-fpm.sock;

nginx -t && systemctl reload nginx

Step 4Switch

Use the same version on the command line

Cron and bin/magento must run with the same PHP as the web server, or they behave differently.

On your server

update-alternatives --set php /usr/bin/php8.3
php -v

Step 5Build

Rebuild and test

Recompile and deploy the static files with the new PHP, flush the cache, and watch the logs while you click through the store and the checkout.

On your server

bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
tail -f var/log/exception.log

Try it on a staging copy first: a broken extension shows up there, not in front of customers.

Questions, answered.

ShopWhizzy support Magento since 2008

Talk to us
Yes. Each version has its own PHP-FPM service, and each site points to the one it needs.
Each PHP version has its own extensions. Install the ones Magento needs for the new version, such as intl, soap, bcmath, gd and zip, before you switch.
Point nginx and the command line to the old version again and rebuild. Keep the old PHP-FPM installed until you are sure.
Yes. Tell us the version, and we test it on staging and switch the live store for you.

Bring your store over. We move it for free.

Pick a plan, pick a platform, and your store is online before the coffee cools.

Prices include VAT. Server support on every plan.