Staying up-to-date and keeping a high-security level are crucial to having a competitive e-commerce store. This article will help you to update your Magento 2 store smoothly and quickly.
Sticking to the point, there are several ways to do it. Let’s review three of them one-by-one.
Before we start, remember that it is always wise to back up files before running an upgrade.
Now, to the methods.
→ Is it time to move to Magento 2? Talk to our migration expert to get answers to all your questions for free. Or order our migration service, we’ll help you migrate your store to M2 without sacrificing the quality.
METHOD #1. USE MAGENTO COMPOSER
The first method is based on using Magento Composer 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. Switch to the Maintenance mode via the command 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 <product> <version> —no-update
Say, you would like to upgrade to Magento 2 CE 2.2.4. Then use the command as in the example:
composer require magento/product-community-edition 2.2.4 —no-update
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:
Username corresponds to the public key and password corresponds to the private key.
After you enter keys, the installation of files will begin.
Step 6. When the installation is complete, you need to clear var child directories. For this, execute the commands below:
rm -rf <Magento install dir>/var/cache/*
rm -rf <Magento install dir>/var/page_cache/*
rm -rf <Magento install dir>/var/generation/*
If you use Varnish, Redis, Memcache, or another caching option, remember to flush them as well.
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. USE THE SETUP WIZARD IN THE MAGENTO ADMIN SIDE
The second method is easier and suits those who are not that good at using Magento 2 Composer.
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.
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.0, M2.1, and M2.2 support different PHP versions.
It is better to back up files manually and skip the backup step suggested by the wizard as it may fail and you`ll have to start the process once again.
METHOD #3. UPLOAD THE LATEST VERSION MANUALLY
This method is the simplest one, so even a Magento 2 newbie can manage it.
Step 1. First, to download the required version, go to the official Magento website. Put downloaded files to 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
Make sure every command is complete before starting the next one.
The above will help you refresh the database schema, update all dependencies, and flush caches. If you have a lot of products, customers, orders, etc., you may need to wait some time until each command is executed.
The upgrade task is almost complete. Now you can check your store frontend 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.
Make your store more visually appealing to customers after upgrading to Magento 2 with the Jet Theme extension
Today we learned to upgrade a Magento 2 store to a later version by using three methods: via Magento Composer, via the Setup Wizard, and by uploading files manually. We can’t say that one of these methods is better than others. In the end, this is a matter of choice to opt for a particular way to upgrade.