Skip to main content
October 15, 202410 min read

Upgrading Magento 2 to the Latest Version in 10 Steps

Get technical support

Patched, monitored, restored on a schedule

A structured 10-step process for upgrading Magento 2 from v2.4.3 to v2.4.7-p3 on Ubuntu, covering system preparation, backups, staging setup, Composer updates, custom module handling, and post-upgrade optimization.

Upgrading Magento 2 to the Latest Version in 10 Steps

Magento upgrades can be nerve-wracking -- especially jumping from v2.4.3 to v2.4.7-p3. There are dependency changes, PHP version requirements, and custom modules that may not play nice with the new codebase. We've done this enough times to have a reliable process. Here's the 10-step approach we use on Ubuntu 24 servers.

Step 1: System Preparation

Start by getting the server's packages current and installing the right PHP version. Magento 2.4.7-p3 supports PHP 8.2 and 8.3. On Ubuntu 24.04, PHP 8.3 is the version the distribution ships.

sudo apt update && sudo apt upgrade -y
sudo apt install php8.3 php8.3-cli php8.3-fpm php8.3-{common,mbstring,xml,curl,zip,gd,bcmath,intl,soap}

Step 2: Back Up the Magento Store

Don't skip this. Seriously. Back up both the files and the database before touching anything.

sudo tar -czvf magento_backup.tar.gz /path/to/magento
mysqldump -u <db_user> -p<db_password> <db_name> > magento_backup.sql

Step 3: Set Up a Staging Environment

Never upgrade production first. Clone the site into a staging environment and initialize Git there for easy rollback.

cd /path/to/staging/magento
git init
git add .
git commit -m "Initial staging setup for Magento upgrade"

Step 4: Enable Maintenance Mode in Staging

Put staging into maintenance mode so nobody accidentally hits it mid-upgrade.

php bin/magento maintenance:enable

Step 5: Set Magento Version in Composer

Tell Composer which version you're targeting, then let it sort out the dependencies:

composer require magento/product-community-edition=2.4.7-p3 --no-update
composer update

Step 6: Database and System Updates

Now run the Magento setup commands. This syncs the database schema, compiles DI, and deploys static content.

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

Step 7: Update Custom Modules in app/code

Here's where things often go sideways. Custom modules in app/code that aren't Composer-managed won't update themselves. You'll need to check each one manually -- if they reference deprecated classes or interfaces, setup:di:compile will fail.

Step 8: Conduct Testing in Staging

Go through the site thoroughly:

  • Browse categories, add products to cart, complete a test checkout
  • Check that extensions and custom themes still render and behave correctly
  • Look for any console errors or broken layouts

Step 9: Upgrade the Live Site

Once staging looks good, repeat the same process on production. Enable maintenance mode first:

php bin/magento maintenance:enable

After the upgrade is done and tested, bring it back:

php bin/magento maintenance:disable

Step 10: Post-Upgrade Monitoring and Optimization

Monitor Logs

tail -f /var/log/magento/system.log
tail -f /var/log/magento/exception.log

Optimize Database

mysqlcheck -o <db_name> -u <db_user> -p

Clear Residual Cache

php bin/magento cache:flush

Benefits of Regular Magento Upgrades

Staying current with Magento versions isn't just about new features:

  • Security -- each release patches known vulnerabilities. Falling behind puts customer data at risk.
  • Performance -- newer versions include optimizations that genuinely speed things up
  • Feature access -- new Magento capabilities keep the store competitive
  • Compatibility -- PHP and server software evolve, and old Magento versions eventually stop working with newer stacks

Troubleshooting Tips

Things that commonly go wrong:

  • Composer dependency conflicts -- try adding the --with-all-dependencies flag. It usually resolves version lock issues.
  • PHP version mismatch -- double-check that PHP 8.2 or 8.3 is actually the active version (not just installed)
  • Custom module failures -- if setup:di:compile throws errors, the problem is almost always in app/code. Check the error messages -- they usually point right at the offending class.

That's the process. It's not glamorous, but it works reliably, and having a tested staging step saves you from the kind of surprises that turn a maintenance window into an all-nighter.

Frequently asked questions

How do I upgrade Magento 2.4.3 to 2.4.7-p3?

Back up the files and database, clone the store into staging, and run the upgrade there first with Git initialized for rollback. In staging, enable maintenance mode, run composer require magento/product-community-edition=2.4.7-p3 --no-update and composer update, then php bin/magento setup:upgrade, setup:di:compile and setup:static-content:deploy -f. After testing, repeat the same steps on production with maintenance mode enabled.

How do I back up a Magento 2 store before an upgrade?

Back up both the files and the database before touching anything. Archive the Magento directory with sudo tar -czvf magento_backup.tar.gz /path/to/magento, and dump the database with mysqldump -u <db_user> -p<db_password> <db_name> > magento_backup.sql. Take both backups before enabling maintenance mode or changing any Composer requirements.

Why should a Magento upgrade run in staging first?

Upgrading production first puts the live store at risk, so clone the site into a staging environment and upgrade there. Initialize Git in the staging copy with git init, git add . and a first commit, so any failed step can be rolled back. Put staging in maintenance mode with php bin/magento maintenance:enable so nobody hits it mid-upgrade.

What Composer commands set the target version for a Magento 2.4.7-p3 upgrade?

Run composer require magento/product-community-edition=2.4.7-p3 --no-update to set the target version, then composer update to resolve the dependencies. If Composer reports dependency conflicts, adding the --with-all-dependencies flag usually resolves the version lock issues.

Why does setup:di:compile fail after a Magento upgrade?

The cause is almost always a custom module in app/code. Modules there are not managed by Composer and do not update themselves, so any that reference deprecated classes or interfaces make php bin/magento setup:di:compile fail. Read the error messages, which usually point right at the offending class, and update each module by hand.

What should be tested after a Magento upgrade in staging?

Browse categories, add products to the cart and complete a test checkout. Check that extensions and custom themes still render and behave correctly, and look for console errors or broken layouts. Move on to the live site only once staging passes all of that.

What should I do after a Magento 2 upgrade goes live?

Disable maintenance mode with php bin/magento maintenance:disable once the upgrade is done and tested, then follow system.log and exception.log with tail -f to catch errors early. Optimize the database with mysqlcheck -o <db_name> -u <db_user> -p and clear any leftover cache with php bin/magento cache:flush.

Why upgrade Magento 2 regularly?

Each Magento release patches known vulnerabilities, so falling behind puts customer data at risk. Newer versions also bring optimizations that speed up the store and new capabilities that keep it competitive. Compatibility matters too, since PHP and server software keep moving and old Magento versions eventually stop working with newer stacks.

Or read how we handle it in Servers Management.