How to Update Magento to Latest Version

April 1, 2021

Introduction

Store functionality, security, and performance should be the focus of ecommerce merchants. Optimize and secure your Magento 2 store by performing regular updates and take full advantage of new features. Built-in Magento features can reduce overhead costs and the need to implement expensive third-party solutions and customizations.

Use one of the following methods to update Magento 2:

  1. Update Magento using the Web Setup Wizard (Magento v2.0, 2.1, 2.2, and 2.3).
  2. Utilize PHP Composer to update Magento.
  3. Manually overwrite core Magento files with the new version.

Learn how to update Magento and ensure that your platform uses the latest version.

Upgrade Magento store to the latest version.

Update Magento via Admin Panel

Updating Magento via the Admin panel is available to merchants using Magento versions 2.0, 2.1, 2.2, and 2.3. The Web Setup Wizard has been depreciated, starting with Magento 2.4.0.

To update Magento from the Admin panel:

1. Expand the System menu.

2. Select the Web Setup Wizard option in the Tools submenu.

Access Web Setup Wizard in Magento Admin.

3. Access the System Upgrade tab.

System Upgrade menu in Magento Web Setup Wizard.

4. Confirm that the Private and Public Keys for your Magento Marketplace account are correct and click Submit.

Verify Magento Private and Public Key.

5. Select the Magento Core Components version from the drop-down menu.

6. (Optional) Include or exclude individual components from the update process by toggling the slider to Yes or No.

7. Click Next to proceed.

Select Magento version and build for upgrade.

8. Select Start Readiness Checks to confirm that the current environment is compatible with the new Magento version.

9. Once the system confirms that the readiness check was successful, click Next.

Perform readiness check before Magento update.

The most common reasons for a failed readiness check are PHP incompatibility, multiple PHP versions on a single system, and conflicting component dependencies. It is essential to resolve all compatibility issues before proceeding with the update.

10. Check the boxes in the Backup Options section to back up the Magento 2 file system (Code), media files, and databases.

11. Click Create Backup to check disk space availability and start the backup process.

Alternatively, skip the Web Setup Wizard backup entirely and create a backup manually using cPanel or a preferred FTP client.

12. Select Next to continue with the update.

Create Magento backup before upgrade.

13. Click Upgrade to start the system upgrade process.

Upgrade Magetno using Web Setup Wizard.

14. A Success notification confirms that the upgrade was successful.

The Magetno Upgrade process is successful.

15. Access the Magento 2 installation directory on your server. In this example, Magento was installed in the magento2.4 sub-directory within the Apache web root (/var/www/html/):

cd /var/www/html/magento2.4

Edit the path to match the Magento root directory path on your system.

16. Use the command-line interface to clear the Magento cache:

php bin/magento cache:clean

17. The var and generated directories are not part of the update. Clear the var and generated sub-directories manually:

rm -rf var/cache/* var/page_cache/* generated/code/*

Visit the Magento storefront and access the Admin to test individual elements and confirm there were no issues with the upgrade process. Review third-party extensions and custom themes as they may need to be updated independently.

Update Magento using PHP Composer

The PHP Composer application helps track dependencies and automates Magento 2 updates. It is mandatory to install PHP Composer if updating to Magento 2.4 or subsequent versions.

Magento 2.4 also requires an extensive stack of software solutions to support its background processes. Find out if your system meets these requirements by visiting the comprehensive How to Install Magento 2.4 guide.

To update Magento with PHP Composer:

1. Establish an SSH connection with the Magento server.

2. Use the command-line interface (CLI) to access the Magento 2 root directory:

cd /var/www/html/magento2.4

Adjust the Magento root directory path to reflect the path on your system.

3. Set the Magento store to maintenance mode:

php bin/magento maintenance:enable
Enable maintenance mode in Magento.

While the store is in maintenance mode, customers are redirected to a default Service Temporarily Unavailable page.

4. (Optional) To review a list of available Magento Open Source 2.4 packages:

composer show magento/product-community-edition 2.4.* --all | grep -m 1 versions

6. Apply the updates with the following command:

composer update

7. Verify the update by entering your Magento authentication keys.

Entering Magento authentication keys.

Log in to your account on the official Magento page and select Access Keys to retrieve the Public (Username) and Private Key (Password).

8. Once the update is complete, clean the Magento cache:

php bin/magento cache:clean

9. Clear the var and generated sub-directories manually using the following command:

rm -rf var/cache/* var/page_cache/* generated/code/*

10. Update the Magento database schema and data:

php bin/magento setup:upgrade

11. Disable the maintenance mode:

php bin/magento maintenance:disable 

12. Confirm the current Magento version:

php bin/magento --version
Check Magento version after update.

Access the Magento storefront and test its functionality and components extensively. If the store is not accessible, it may indicate that permissions for the var and pub directories are incorrect. Utilize a user with root privileges to reset file system ownership and permissions.

Update Magento Manually by Overriding the Old Files

If you are running Magento on a local server for testing purposes, you can easily update the software by overwriting the old system files.

1. Download the Archive file for the new Magento build version and format you want to upgrade to. The compressed zip and tar files are available on the official Magento download page.

Official Magento Archive download page.

2. Unzip the downloaded archive in the Magento root directory. The new files are going to overwrite the existing system files.

3. Access the Magento root directory using the command line. Enter the following commands to update the database schema and data, update dependencies, clean the cache, and reindex the indexers:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento indexer:reindex

Test store performance and confirm that the payment flow and payment processing, customer orders, and shipping methods work correctly. Check extensions and themes to assess if they are fully compatible with the new version.

Conclusion

You have successfully updated your Magento store to the latest version. Regularly updating Magento is not only a necessity from a security standpoint but also brings clear competitive advantages in a crowded ecommerce field.

Using this opportunity to install a new Magento theme can help your store stand out and improve conversion rates considerably.

About the author
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at CCBill. He has more than 8 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His engaging writing style provides practical advice and aims to spark curiosity for innovative technologies.
Talk to a Merchant Support Specialist
cross