How to Upgrade Magento 2 to the Latest Version [3 Methods]
Magento 2 is one of the most popular and flexible e-commerce platforms designed to meet the demands of modern online businesses. With its robust framework, Magento 2 offers a range of tools that support various aspects of e-commerce, from product management to payment gateways. But like any software, staying on the latest version is crucial to keeping your site secure, optimized, and in line with the latest industry standards.
This article, researched by Mageplaza’s specialists, will provide you with 3 methods to upgrade the Magento 2 store to the latest version, which ensures that your store stays ahead of the competition. Let’s discover now!
Looking for
Upgrade Services?
Upgrade your Magento 2 store to the latest version for new features and security - with the help of our dedicated experts.
Upgrade nowWhy Should You Upgrade Magento 2 to the Latest Version
There should be increased awareness that doesn’t allow outdated websites to hinder your business operations. Magento 2 Upgrade to the latest version is necessary because it brings many benefits that help your online store be secure and stable. Here are specific reasons why you need to update to the latest Magento 2 version:
-
Security enhancement: Upgrade Magento often comes with security updates, significantly reducing vulnerabilities to hacks, cyber-attacks, and potential instability within E-commerce platforms.
-
Performance improvements: An upgraded version not only ensures fast site speeds and visually appealing redesigned pages but also optimizes load times for all elements. Therefore, the optimization contributes to improved website performance and conversion rates.
-
New features & functionalities: Updating the latest Magento 2 version will elevate website management efficiency. Besides, it is also considered an effective cost-saving measure, mitigating reliance on external third-party integrations.
-
Infrastructure enhancements: The Magento upgrade updates the code quality and infrastructure. While these advantages might not be immediately apparent, they play a vital role in elevating the overall health of your site and optimizing the efficiency of on-site development work.
-
Remediation of issues in the existing version: Upgrading to the latest Magento 2 version can help fix any existing issues, making your online store run smoothly.
Prepare for the Latest Magento 2 Upgrade
-
PHP Compatibility: Ensure your PHP version is compatible with the Magento version you’re upgrading to.
-
Mysql Compatibility: Make Sure your Mysql/MariaDB version is compatible with Magento.
-
Backup: Always back up your Magento store before performing any upgrades.
-
Creating backups for your Magento 2 site: It is so urgent and necessary that you can protect all data from disappearance through Backup Management if there is any change or break on the site. Follow this guide to backup your Magento 2 store.
3 main methods to upgrade Magento 2 to the latest version.
Below is a detailed explanation of each of the upgrade methods.
1. Upload Magento 2 Manually
By manually uploading the most recent Magento 2 version to the root directory, you can upgrade Magento 2 to the latest version. This is the simplest way to use many upgrading methods. To manually upgrade Magento 2 simply follow these steps:
Step 1. Download the Latest Magento 2 Version
Install the most recent version of Magento 2 by downloading the zip file and placing it in the root directory. If the system prompts you to replace existing files, select “Yes” and unzip the file.
Step 2. Run SSH Commands
After extracting the Magento package in the root directory, run the following commands one by one in the SSH console:
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento indexer:reindex
The above commands will refresh the database schema, update all dependencies, and flush caches. When everything is finished, you can check the Magento 2 admin panel and frontend to make sure the upgrade went smoothly.
2. Magento 2 Upgrade via Composer
Upgrading Magento via composer is an ideal method for every Magento 2 user. To make this possible, please just follow 4 following steps:
Step 1: Turn on maintenance mode
You should put your store in maintenance mode while upgrading. To enable maintenance mode:
php bin/magento maintenance:enable
It will create a new file var/.maintenance.flag
. If you cannot disable maintenance mode, you can remove this file [Remmember!]
Step 2: Upgrade to Magento 2
In this case, I will upgrade to Magento version 2.4.7
. See the latest releases on Download page, Github releases
Step 2.1 Pull package
Using the following command on terminal/command-prompt
firstly:
composer require magento/product-community-edition 2.4.7 --no-update
composer update
Replace product-community-edition with the specific Magento package you’re upgrading to.
You may be asked for a username and password like this:
To generate Public/Private Key pair please read this
Run: composer upgrade magento/composer-root-update-plugin
Step 2.2 Flush cache
Now time to remove cache and generation. Run the following command line at the root folder:
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*
Notes:
- You may install Memcached, Redis cache…, you should flush those caches manually.
Step 2.3 Run Upgrade Magento
Run upgrade module, database schema
php bin/magento setup:upgrade
Step 2.4 Run compile, reindex
You should run compile and reindex for better performance after upgrading.
php bin/magento setup:di:compile
php bin/magento indexer:reindex
Notes:
- In Ubuntu/Debian Linux, when you meet permission issues, remember to insert
sudo
at the beginning of every command likesudo composer update
.
Step 2.5 Disable maintenance mode
You have turned on maintenance mode in step 2, now you have to turn it off. Run the following command line to turn it off:
php bin/magento maintenance:disable
Step 3: Check the current Magento 2’s version
Next, you can check the Magento 2’s version by running the command.
php bin/magento --version
If the system shows the cache write permission error, please add the following command to give write permission to pub and var directories:
chmod -R 777 pub var
3. Using Magento 2 Web Setup Wizard
Note: Only older Magento versions can still be upgraded using this method. With the starting with Magento 2.4.x, the Magento Web Setup Wizard has been discontinued.
Step 1: Go to Magento 2 Web Setup Wizard Log into your Magento 2 admin panel, and go to System > Tools > Web Setup Wizard.
Step 2: Add Authentication Keys to System Configuration In the Magento Setup Tool > click on System Configuration > add the authentication keys received from your Magento account, and save the configuration.
Step 3: Run System Upgrade
Finally, click the System Upgrade option to perform the Magento 2 version upgrade. Note that you may also be asked to upgrade the PHP to the latest version during the process.
Control theme and extension updates
Updating themes and extensions is important after upgrading your Magento 2 platform. It will ensure compatibility and prevent potential issues that affect your store’s appearance and functionality.
For those using a custom-made theme, contacting the developers and requesting an audit to ensure compatibility with the latest Magento 2 version is recommended.
Besides, it is necessary to have front-end monitoring to ensure no misaligned or missing content, as this can significantly damage your store’s visual integrity.
Common Magento Upgrade Issues and How to Fix
When upgrading Magento, you may encounter some common issues. Here are some of the most common issues and how to fix them:
Addressing Component Dependency Conflicts
Upgrading Magento may encounter component dependency conflicts, potentially arising from incorrect edits to the JSON composer file or compatibility issues with third-party extensions. Resolving these conflicts is crucial for a successful upgrade.
To solve this issue, you should follow these things:
-
Restore the JSON Composer File: Start by restoring the JSON composer file. Ensure that the file accurately reflects the necessary dependencies for the upgrade process.
-
Incompatibility with third-party modules: It is necessary to check for updates available for the problematic module. If updates are found, install the latest version of the module. But if there are no updates available, you can disable the problematic module.
Resolving The “Cannot Create the Directory” Error
Encountering the “Can’t Create Directory” error is a common issue that can happen when you update Magento 2. This error often arises due to permission issues with directories and files under Magento’s var subdirectory.
To address this error, run the command: “php bin/magento setup:di:compile” to ensure that the necessary directories and files have the correct permissions.
Fixing The “Cannot Allocate Memory” Error
Cannot Allocate Memory error is also one of the common issues that occurs when the system has exhausted its available memory or swapped space.
Here’s how to tackle it effectively:
-
Optimize Memory Usage: Review and optimize Magento’s memory usage. Identify any extensions or processes consuming excessive memory and make necessary adjustments.
-
Consider Server Upgrade: If memory constraints persist, consider upgrading the server’s RAM or your server plan to accommodate the additional memory requirements.
-
Check for Memory Leaks: Detect and fix any memory leaks in your Magento installation. Addressing these leaks can prevent the recurrence of the “Cannot Allocate Memory” error.
FAQs
Q1: What is the process for upgrading Magento?
Answer:
To upgrade Magento, you can follow these specific steps:
- Backup Your Store: Always start by creating a backup of your store’s files and database to ensure you can restore the previous state if needed.
- Enable Maintenance Mode: This will prevent customers from accessing the store while the upgrade is in progress.
- *Upgrade Using Composer**: If you’re using Magento 2, you can upgrade your installation using Composer. This involves running commands to update Magento’s software dependencies.
- Update the Database: Run the Magento setup upgrade command to update the database schema and data.
- Disable Maintenance Mode: Once the upgrade is complete and you’ve ensured everything is working correctly, disable maintenance mode.
- Remove the var/di Directory: Erase the var/di folder from your Magento installation.
- Adjust Permissions: Set the permissions of the var and pub directories to 777 to ensure Magento can write to these folders.
- Run Setup Commands: Run the
setup:upgrade
command to upgrade the setup, followed bysetup:di:compile
to compile the dependency injection configurations.
Q2: How do I upgrade Magento 2 to 2.4.7?
Answer:
To upgrade Magento 2 to version 2.4.7, back up your data before starting the upgrade process and check the compatibility of your extensions and customizations with the new version. The next step you should do is to:
Download the Latest Magento 2.4.7 Version: Obtain the zip file of Magento 2.4.7 and upload it to your root directory. Replace Existing Files: When prompted, agree to overwrite the existing files and unzip the new version. After uploading and extracting the files, run these SSH commands in sequence:
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento indexer:reindex
Q3: I cannot access to frontend after upgrading. You may got this message: We’re sorry, an error has occurred while generating this email.
Answer:
That is because of read-write perrmissions for the web server. Run the following command to resolve it: find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento
Flush cache again:
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*
Q4: What is the difference between Magento Open Source and Adobe Commerce?
Answer:
Magento Open Source is considered a free, open-source version ideal for small to medium-sized businesses. It offers a flexible and customizable environment, allowing businesses to adjust the platform to their specific needs. However, it requires users to manage their own hosting and may involve additional development and hosting fees.
While Adobe Commerce is a paid, premium version suitable for larger enterprises, it builds on the foundation of Magento Open Source by adding advanced features and tools designed to enhance the eCommerce experience. Adobe Commerce also offers a cloud version, which includes hosting services to simplify business infrastructure management.
For a detailed comparison, please follow the article Magento Open Source vs Adobe Commerce - Make the Right Business Choice.
Q5: What are the main benefits of upgrading Magento?
Answer:
There are many key benefits of upgrading Magento, including:
-
Enhanced Security: Protects against cyber threats and ensures customer data safety.
-
Improved Performance: Optimizes speed and efficiency for a better user experience.
-
Access to Advanced Features: Use new and improved functionalities that were not available in previous versions.
Q6: Is there a Magento upgrade service?
Answer:
Yes, Magento upgrade services are available to assist with the Magento 2 upgrade process. These services offer expert teams that specialize in helping you update your Magento store. Working with a Magento upgrade service is recommended if you’re considering updating your store.
Q7: How can I backup my Magento 2 store?
Answer:
To create a store backup before upgrading Magento, you can use the Magento 2 backup tool or choose a third-party backup tool. It’s vital to back up your store before initiating any upgrades to prevent data loss and enable recovery if needed.
Upgrade Magento 2 Service
Finding it too complicated?
Don’t worry; Mageplaza are dedicated to helping you enhance your Magento 2 store to its fullest potential. Our Magento Upgrade Service is designed to seamlessly upgrade your store to the latest version, ensuring improved performance, enhanced security, and access to the latest features.
Our team of experienced Magento developers will handle every aspect of the upgrade process, from thorough pre-upgrade analysis to post-upgrade testing, ensuring a smooth transition with minimal downtime. With Mageplaza, you can rest assured that your Magento 2 store will be up-to-date and ready to provide your customers with an exceptional shopping experience.
Upgrade your Magento 2 store with confidence. Choose Mageplaza Upgrade Magento 2 Service today and take your online business to new heights.
- How to create a simple Hello World module for Magento 2
- Magento 2 Block Template Ultimate Guides
- How to Create Module in Magento 2
- How to Create Controller in Magento 2
- How to create CRUD Models in Magento 2
- How to Create Magento 2 Block, Layout and Templates
- Configuration - System.xml
- How To Create Admin Menu In Magento 2
- Admin ACL
- Admin Grid
People also searched for
- magento 2 upgrade update via command line composer
- magento 2 upgrade composer
- magento 2 module:upgrade command
- upgrade magento 2 command line
- magento 2.1 upgrade
- magento 2 upgrade command
- magento 2.1.2 upgrade
- magento 2 update
- magento 2 upgrade
- magento 2 system upgrade
- magento 2 update via command line
- upgrade update via command line in magento 2
- update via command line in magento 2
- magento 2 version upgrade
- how to upgrade magento 2 to latest version
- update magento 2 to latest version
- 2.3.x, 2.4.x