Magento 2 is the eCommerce platform and software utilized by the world's top firms. Magento 2 (Adobe Commerce) is a favored eCommerce platform due to its unquestionable advantages. A great extension ecosystem and eCommerce functionality with a high level of support are examples of common advantages.
This article explains how to upgrade the Magento 2 version using the command line and composer. Let's follow this guide in sequential order.
Step 1: Backup your store
Creating backups for your Magento 2 site is so important and vital that you can protect all data from oblivion using Backup Management in the event of a site malfunction.
Step 2: Turn on maintenance mode
During the course of the upgrade, you should put your store into maintenance mode. 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
Step 3: Upgrade to Magento 2
See latest releases at Github releases
In this case, I'll upgrade to Magento version 2.2.1
Step 3.1 Pull package
Using command: terminal/command-prompt
Enter your username and password that you created
Step 3.2 Flush cache
Remove cache and run the following command line at root folder:
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*
Step 3.3 Run Upgrade Magento
Run upgrade module, database schema
php bin/magento setup:upgrade
Step 3.4 Run complie, reindex
php bin/magento setup:di:compile
php bin/magento indexer:reindex
Step 3.5 Disable maintenance mode
In step 2, you turned on maintenance mode; the next step is to turn it off. To disable it, execute the following command line:
php bin/magento maintenance:disable
Final words
Upgrading Magento 2 to the latest version improves performance for online businesses because many innovative and incredible features.
However, the upgrading process isn’t that easy, complex and straightforward. It requires knowledge and skills to transfer the data. So I recommend you need to Magento upgrade service if you are not skilled and experienced enough in Magento.