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. But there’s even more to it than you think:
- Improved performance and scalability – Magento 2 uses the latest technologies and code optimizations, offering faster page load times and better overall performance.
- Enhanced security – Get improved security features and updates that are essential in protecting your online store and customer data.
- Mobile-friendly and responsive design – The new version comes with a responsive design out of the box, which is crucial as mobile shopping continues to rise in popularity.
- Streamlined checkout process – Embrace a more user-friendly and streamlined checkout process that will help you reduce cart abandonment rates and improve the shopping experience for customers.
- Admin interface improvements – The admin panel has been revamped and made more intuitive, making it easier to manage products, orders, and customer data.
- SEO-friendly features – Magento 2 includes built-in SEO features and supports modern SEO practices, helping your store rank better in search engines and improve online visibility.
- Integration capabilities– Magento 2 offers better integration possibilities with third-party tools, payment gateways, and shipping providers.
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 Magento 2 version, preparation is key. Follow these steps to ensure your upgrade is trouble-free:
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
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.
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.
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.
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:
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:
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:
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 a Critical Issue in Magento 2.4.7
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.
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.