Upgrade Magento 2 using Composer

Magento 2 Version Upgrade - How to cross that bridge

Upgrade Magento 2 to the latest version using Composer

[aMiSTACX] Make sure everything is working BEFORE you attempt to upgrade. Also, plan your PHP version ahead of time.

Pre-Upgrade Recommendations

  • We will take a manual full image before we start. [You can also use A51’s instant backup.]
  • sudo php bin/magento deploy:mode:set developer
  • Disable ALL 3rd party and Magento nonessential modules you are not using.
  • sudo ./amistacx.sh [Compile Script in /magento/]
  • sudo composer update
  • sudo ./amistacx.sh

Everything should be clean with no errors before attempting to upgrade.

Upgrade Recommendations

Warning: DO NOT upgrade composer to 2.x! Magento only supports 2.x in version 2.4.2+. You can install both versions of Composer.

Note: If you need to upgrade from 2.2.0 to 2.3.x, please follow the steps in this article:

So here we go in my example I will update from 2.4.0 to 2.4.3:

cd /var/www/magento

sudo php bin/magento deploy:mode:set developer

sudo php bin/magento maintenance:enable

sudo php bin/magento cache:clean

sudo systemctl stop elasticsearch.service

sudo composer require <product> <version>

e.g sudo composer require magento/product-community-edition 2.4.3

Note: May accept -W or –update-with-dependencies

sudo composer config --global discard-changes true

sudo chown -R www-data:www-data /var/www/magento

sudo chmod -R u+rwX,go+rX,go-w /var/www/magento

sudo composer update

Note: If you get a prompt saying: “Discard changes [y,n,v,d,s,?]?” Normally you would select “y”, or you can run composer update with -n [No Interaction]

Error or Prompts – at this point hopefully you will not get any errors, and if so you’ll have the ability to resolve by accepting composer’s versioning. By no means can we cover all of the potential issues here :/

If you made it past update, then it should be clear sailing.

sudo systemctl start elasticsearch.service

sudo ./amistacx.sh #Should be version 1.1+ for Magento G5 stacks.

Test in Prod mode or Dev mode

sudo php bin/magento deploy:mode:set production

sudo chown -R www-data:www-data /var/www/magento

Advanced Troubleshooting

If you get a message like this on your homepage:

Amazon_Core db schema version: defined in codebase – 2.1.2, currently installed – 2.2.10
Amazon_Core db data version: defined in codebase – 2.1.2, currently installed – 2.2.10

You need to connect to the database, go to the setup_module table, and LOWER the number to match what is defined in the codebase for each module that throws the exception.

Switch PHP Versions

Please see your stack guide on how to switch PHP versions. G6 stacks support 8.1 and 7.4, G5F and G5SP stacks support PHP 7.2 ~ 8.0. All of our G4 Magento stacks support PHP 7.3 ~ 7.1. Newer stacks have switch scripts in the utility folder.

Weaponize your Business with aMiSTACX!