How to Upgrade Magento 2 to The Latest Version: 3 Easy Methods

Table of Content

how to upgrade Magento

If you're a Magento store owner, you already know that staying up-to-date with the latest technology is key to ensuring your online business thrives. As Magento constantly grows and innovates, upgrading to the latest version can help you uncover new powerful features.

This guide will walk you through how to update Magento. We’ll cover the benefits, preparation steps, and detailed instructions on how to upgrade Magento version to ensure a seamless experience.

Read More: The Key Benefits of the Latest Magento Version

Why Upgrade Magento 2?

You may be exploring how to upgrade Magento 2 to the latest version to leverage the new features. Alternatively, you’re looking into how to upgrade Magento 2 to avoid security vulnerabilities. 

Magento updates indeed typically include critical security patches, performance enhancements, and new functionality. Here's a full list of updating benefits:

  • Enhanced Security: Each Magento update addresses vulnerabilities to keep your store and customer data safe.
  • Improved Performance: Updates often include optimizations for faster page load times and better scalability.
  • Access to New Features: Stay competitive with the latest tools and functionalities Magento offers.
  • Bug Fixes: Resolve issues from previous versions to ensure smoother operations.
  • Compatibility Updates: Ensure your store works seamlessly with the latest extensions, themes, and integrations.
  • Compliance with Regulations: Keep your store compliant with evolving industry and data protection standards.
  • Support from Adobe: Older versions may not receive official support, leaving your store at risk.

In short, staying up-to-date with Magento Open Source and Adobe Commerce updates ensures your store runs optimally, securely, and provides a great customer experience.

Read More: Magento CVE-2024-20720 Vulnerability – Is Your Store Still at Risk?

How to Prepare for Magento Upgrade

When tackling how to upgrade any Magento 2 version, preparation is important. Follow these steps to ensure your upgrade is trouble-free:

1. Back Up Your Store

Before proceeding with any Magento update, start by creating a complete backup of your Magento store, including files and the database. This safeguard allows you to revert to the previous version in case of any issues during the upgrade.

Pro tip from Amasty: The simplest variant of Magento backup can be implemented using these two commands:

tar -czf ~/magento-files.tar.gz -C /home/mgtest public_html
mysqldump --add-drop-table -h
localhost -u mgtest -p mgtest_magento | gzip > ~/magento-db.sql.gz

In case your Magento version update goes wrong, you can easily roll everything back:

cd /home/mgtest
mv public_html public_html-BAK
tar -xzf ~/magento-files.tar.gz
gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u mgtest -p mgtest_magento

2. Check System Requirements

Verify that your server meets the system requirements for the new Magento version. Take a look at the PHP version (5.4.x or 5.5.x is needed) and memory_limit value in php.ini in the first place.

3. Review Third-party Extensions

Examine all installed extensions for compatibility with the new version. Make a list of these extensions and consult their providers for any necessary updates or patches.

4. Test in a Staging Environment

If possible, replicate your live environment in a staging setup. Perform the upgrade here first to identify any potential issues without affecting your live store.

5. Prepare for Downtime

Inform your customers about potential downtime during the upgrade process. Schedule the upgrade during off-peak hours to minimize disruption and enable maintenance mode to let those accessing your store know what’s up.

Once you address all of these aspects, you can prevent potential roadblocks during the Magento 2 upgrade process.

Magento 2 How to Upgrade Version: Staging and 3 Methods

Of course, the safest way to upgrade Magento is to request professional Magento upgrade services. Seasoned Magento developers will perform all the necessary tasks, guaranteeing quick results with no data errors or damage. At Amasty, we also strive to perform Magento upgrades with minimum downtime, allowing you to keep doing business as usual. 

Still, if you're tech-savvy enough, you can try to perform the Magento update by yourself.

Setting Up a Staging Environment

We advise you to not update the primary website if you’re not 100% sure everything is ready to go. If you don’t test the update on a sandbox environment, you won’t know if the website will function properly after the update or how long the upgrade process will take.

Your store’s upgrade may require several hours, and there’s no point in shutting down the primary store for an entire working day just to discover that the upgrade went wrong. If that happens, you’ll lose valuable time and be left with the task of restoring the website from a backup. Remember that recovering from a backup can take more time than the backup process itself, so factor that into your timeline.

To ensure that the update runs smoothly, let’s create a sandbox environment that we will upgrade first.

cd /home/mgtest
mkdir public_html/staging
tar -xzf ~/magento-files.tar.gz --strip-components=1 -C public_html/staging
gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u mgtest -p mgtest_staging

Now it’s time to set the sandbox up:

  • Edit the database connection settings in public_html/staging/app/etc/local.xml
  • Go to mgtest_staging database, find core_config_data table and change the website’s URL. Say, the old URL was http://mgtest.local/, then the new one will be http://mgtest.local/staging/
  • If your Magento store uses Apache rewrites, then add RewriteBase /staging/ in public_html/staging/.htaccess
  • Turn compilation off at System > Tools > Compilation
  • Disable cache at System > Cache Management

Now the sandbox is ready to be upgraded according to any of the 3 upgrade methods below.

Method #1 – Upgrade via Magento 2 Composer

The first method is based on using Magento 2 Composer for upgrade and includes the following 8 steps.

Step 1. Logged in as a system owner (root user), navigate to the Magento 2 root folder cd ~ /public_html

Step 2. Enable maintenance mode via the command line by typing: php bin/magento maintenance:enable

Step 3. Clear everything in the vendor folder by running the command rm -rf vendor/*

Step 4. Open the composer.json file and change the current version of your Magento to the required one, as in the screenshot below:

Check Magento 2 version in the json file.

Alternatively, you can execute the Require command to request the Magento 2 package to use Composer and update associated files:

composer require   —no-update
composer update

Say, you would like to upgrade to Magento 2 CE 2.4.7. Then use the command as in the example:

composer require magento/product-community-edition 2.4.7 —no-update
composer update

Pro tip from Amasty: You can use Composer to upgrade Magento to any version you need, for example, perform a Magento upgrade from 2.4.3 to 2.4.6.

Step 5. Specify access keys if needed. You can get them using the following link. This is what you will see after you log in:

magento 2 access keys

The username corresponds to the public key and the password corresponds to the private key.

After you enter the keys, the installation of files will begin automatically.

Step 6. When the installation is complete, you need to clear var child directories. To do this, execute the commands below:

rm -rf /var/cache/*
rm -rf /var/page_cache/*
rm -rf /var/generation/*

Pro tip from Amasty: If you use Varnish, Redis, Memcache, or another caching option, remember to flush them too.

Step 7. After clearing subdirectories, use another query to upgrade the database schema:

php bin/magento setup:upgrade

Step 8. Disable the Maintenance mode and put your store back to work by running the command:

php bin/magento maintenance:disable

Method #2 – Upgrade via Magento 2 Setup Wizard

For those new to Magento upgrades, using Magento 2 Composer can be challenging. However, the second method we offer is much easier and more automated. 

Magento provides a built-in web-based setup wizard that allows you to perform upgrades directly from the admin panel. This method is suitable for you if you have a relatively small store with simple setups and minimal customizations.

Step 1. Access your store admin side as a user with full permissions (super-admin).

Step 2. Navigate to System > Tools > Web Setup Wizard. You will see the following menu:

Access the Magento 2 setup wizard.

Step 3. Select the System Configuration option.

You may be asked to specify authentication keys in the corresponding fields. Again, you can get the keys on Magento Marketplace (see the link above).

Step 4. Click Save config and then System Upgrades.

Pro tip from Amasty: Back up files manually and skip the backup step suggested by the wizard. Wizard's backup often fails midway and you'll have to restart.

During the upgrade process, you will get detailed instructions so there shouldn't be any issues. Note that, at the Readiness check process step, you may be asked to upgrade PHP since M2.3, and M2.4 support different PHP versions. 

Method #3 – Upgrade to the Latest Version Manually

This method may seem simple, but it can be more time-consuming and error-prone. For stores with numerous customizations or extensions, the risks of data conflicts and damage are particularly high. We advise using this option only if your store has very minimal customizations.

Step 1. First, go to the official Magento website to download the required version. Put the downloaded files into the Magento 2 root folder and unzip the package.

Step 2. If Magento asks to replace existing files, click ‘Yes’. Then, in SSH console, run the following commands one by one.

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

Pro tip from Amasty: Make sure every command is complete before starting the next one.

The listed PHP bin Magento upgrade commands will help you refresh the database schema, update all dependencies, and flush caches. If you have a large number of products, customers, orders, etc., you may need to wait for each command to execute.

Step 3. Once you're done, check your store front end and admin view to ensure that everything looks and works as expected. If you use third-party extensions, run some smoke tests to check that these modules are still compatible with your new Magento version and upgrade them as well if needed.

Testing Magento After an Upgrade

Once you have successfully upgraded your Magento store, you need to test it to ensure everything functions correctly. 

Follow these steps:

  • Check frontend functionality – Navigate through your store’s frontend to verify that all pages load correctly, products are displayed accurately, and the checkout process works seamlessly.
  • Test admin panel access – Log into the admin panel and check if all functionalities are operational, including product management, order processing, and customer data access.
  • Verify third-party extensions – Run tests on all third-party extensions to confirm they are compatible with the new version of Magento. Look for any errors or malfunctions and update or replace extensions as needed.
  • Run performance tests – Utilize performance testing tools to assess page load times and overall site performance post-upgrade. Ensure that there are no significant slowdowns compared to the previous version.
  • Monitor logs for errors – Check Magento’s logs for any errors or warnings that may indicate issues stemming from the upgrade process. Address any problems promptly.

Note: Please, make sure that you carefully test the performance of your extensions. If you upgrade to the latest and fresh version of Magento, the chance some extensions will work with errors or conflict with each other is rising, because not all Magento extension providers test their modules right away after the release.

Troubleshooting Common Magento Upgrade Issues

Unfortunately, even with good preparation, there’s no guarantee that you won’t encounter issues during or after a Magento upgrade. Here are some common problems and their solutions:

  • Incompatibility with extensions – Check for updates from extension developers and apply them. If an extension is incompatible, consider disabling it or finding an alternative.
  • Slow loading times – If your store has become slow after the upgrade, clear all caches (including Magento cache, browser cache, and any server-side caches like Varnish or Redis). Additionally, review your server resources to ensure they meet the new version's requirements.
  • Database errors – If you encounter database errors or missing tables, run the command php bin/magento setup:upgrade to update the database schema. If issues persist, check the logs for specific error messages and address them accordingly.
  • Theme display issues – If your theme is not displayed correctly after the upgrade, ensure that any customizations are compatible with the new version. You may need to update your theme or apply patches. 
  • Admin panel access problems – Clear browser cache and cookies. If problems persist, check for permission issues in your server settings or review log files for error messages.

Read More: How to Fix Common Issues in Magento 2

Wrapping Up

Knowing how to update Magento version or how to upgrade Magento 2 can seem difficult but with the right preparation and tools, it becomes manageable. When you stay proactive with your Magento 2 upgrade, you can enhance your store's performance, security, and features. 

Make sure to realistically assess your technical prowess and always feel free to reach out to Amasty's team for tips, guidance, or hands-on help.

Frequently asked questions

The duration of a Magento upgrade depends on various factors, including the size of your store, the complexity of customizations, and the method used for the upgrade. On average, it can take anywhere from a few hours to a full day.

If you have custom extensions, it’s important to review them for compatibility with the new version of Magento. Check with your developers or extension providers for updates or modifications needed to ensure they function correctly after the upgrade.

While upgrading to the latest version is not mandatory, it is highly recommended. New versions include important security patches, performance improvements, and new features that keep your store protected.

To upgrade Magento 2 to the latest version, use the methods described in this article: back up your store, update the composer.json file, run Composer commands, and verify the upgrade with maintenance checks

Customizations may be affected during an upgrade, especially if they are tied to outdated extensions or themes. It’s important to review all custom code and ensure compatibility with the new version before upgrading.

July 4, 2018
July 9, 2018
June 26, 2018
Comments
Syed Muneeb Ul Hasan
July 16, 2018
I think users normally use method 1 "Command", even me :) Thanks for sharing this great tutorial.
Reply
Alina Bragina
July 19, 2018
Hi there, thanks for taking the time to leave your feedback! We are glad to share our experience and be helpful. Cheers!
Guest
September 10, 2019
5
Reply
Peter miller
December 16, 2019
Hi, Thank you for writing such an informative blog. I’m planning to upgrade to Magento 2 and this blog has taken away all my confusions and worries regarding the migration process. I had no idea there are several ways to so.
Reply
Polina Litreyeva
December 20, 2019
Hello! Thanks for sharing your opinion. If you need help, feel free to <a href="https://amasty.com/contacts/">contact us</a>.
Yogesh
March 6, 2020
Hi Team, I'm trying to update magento 2.2.1 to 2.2.11 with METHOD #3. UPLOAD THE LATEST VERSION MANUALLY but unfortunately, the result is nothing.
Reply
Polina Litreyeva
March 9, 2020
Hello, Yogesh! Thanks for the feedback! Pity, you have the issue. You can try to update your system with the first 2 methods, or check the <a href="https://devdocs.magento.com/guides/v2.3/comp-mgr/upgrader/upgrade-checklist.html" rel="nofollow">official Magento documentation</a> for more info. Unfortunately, we need to dive deeper into the system itself to understand why an error occurred. Sorry, but that is why we won’t help you in the comments. Cheers!
Yogesh
March 10, 2020
Hello, Polina Thank you for your update I have tried with the first method i.e METHOD #1. USE MAGENTO COMPOSER everything is working fine and version also updated but please check the below points why I'm getting while using COMPOSER UPDATE command Package zendframework/zend-text is abandoned, you should avoid using it. Use laminas/laminas-text instead. Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead. Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead. Package zendframework/zend-view is abandoned, you should avoid using it. Use laminas/laminas-view instead.
Polina Litreyeva
March 13, 2020
Hi, Yogesh! Laminas is a new name of the Zend Framework. It seems like you got these notifications because you need to migrate to Laminas-branded packages. For more info, please check the<a href="https://www.zend.com/blog/evolution-zend-framework-laminas-project" rel="nofollow"> official Zend Framework explanation</a>. Cheers!
Me
February 15, 2021
Hi, I have read your guide: https://amasty.com/blog/3-ways-to-upgrade-your-magento-2/ Why do I need to do this command at step 3? rm -rf vendor/* In the vendor directory there are all kinds of extensions which would be removed. I can not see anywhere in your guide that these are being reinstalled. When doing the upgrade via download/copy/paste the vendor files get untouched which would make more sense to me.
Reply
Vladimir Derachits
February 22, 2021
Hi there, thanks for the feedback. You see it’s difficult to answer from here. Please, check out the <a href="https://devdocs.magento.com/guides/v2.4/install-gde/composer.html" rel="nofollow">official magento installation guide</a> to get more deatials about the installation process.
Steve ways
June 25, 2021
Magento is one of the best E-commerce platforms built on open-source technology. Thanks for sharing the informative article.
Reply
Vladimir Derachits
July 6, 2021
Hi Steve, thanks for your feedback! We are glad to share our experience and be helpful.
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro