How to update Magento using composer
Magento has officially announced that they will stop Magento 1 support by June 2020. Therefore, update Magento store to higher version is important, because you should stabilize your online business activity as soon as possible. There are multiple ways to update Magento store. If you are really good at dealing with tech work, this article will guide you on how to update Magento using command-line.
1. Put your store in maintenance mode to update Magento:
Before updating Magento 2 using command-line, you need to put your store in the maintenance mode and back up your data. This will prevent access to your store during the upgrade process and avoid risks in case you operate incorrectly. It also means your store will stop business activity for a while or days.
Here is the way to enable this mode:
- Firstly, log in to your Magento server > the Magento file system owner.
- Enter the following command:
php <your Magento install dir>/bin/magento maintenance:enable
2. Upgrade using Command line:
Step 1: Log in to your Magento server as, or switch to, the Magento file system owner.
Step 2: Change to the directory in which you installed the Magento software.
For example: cd /var/www/html/magento2
Step 3: Enter the following commands:
composer require <product> <version> --no-update
For example, to upgrade to Magento Open Source version 2.0.14, enter:
composer require magento/product-community-edition 2.0.14 --no-update
Step 4: Then enter your authentication keys.
- Log in to the Magento Admin as an administrator
- Click System > Tools > Web Setup Wizard
- Click System Configuration
- Enter your public and private authentication keys in the provided fields
- Click Save Config
Step 5: Manually clear var subdirectories:
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 a cache storage other than file system (e.g., Redis, Memcached, etc.) you need to manually clear the cache there too.
Step 6: Update the database schema and data:
Step 7: Put your storefront online (it means to disable the maintenance mode):
php bin/magento maintenance:disable
Step 8: Restart Varnish if you use it for page caching
Step 9: Access your storefront.
The following error might display: We’re sorry, an error has occurred while generating this email.
Please perform the following tasks:
- Reset file system ownership and permissions as a user with root privileges.
- Clear the following directories and try again:
<your Magento install dir>/var/cache
<your Magento install dir>/var/page_cache
<your Magento install dir>/var/generation
Lastly, after the upgrade, again check your Magento version with the following command:
php bin/magento —version
Finally, if you find this update way too complicated and potential of risk, you can use LitExtension Migration App to do it. LitExtension is designed for all users and requires no technical and programming skills. You also can follow How to upgrade Magento 2 with LitExtension here.