Magento 2 is the latest major release of the Magento eCommerce platform which is available in both the community and enterprise editions. Magento keeps releasing the updates to keep the platform secure and up-to-date with latest new requirements.
This article provides a complete guide for upgrading a Magento 2 store using the composer. Magento 2 with its command line interface saves a lot of time for the developers in module management, cache management, updates and lot more. That’s why we are going to use the Command Line Interface to update the Magento 2 here.
Here are the following reasons for why you should update Magento 2:
- For keeping your website secure with latest Security Patches
- For getting new UI Updates For Functionality Improvement
- For Bug Fixes For support of Latest Features
- For Website Speed and Performance Improvement
- For New Payment Methods Support For improved integration with 3 party Magento 2 extensions, Google Analytics, Shipping Methods, Payment Gateways etc.
You can use the Magento 2 Command Line Interface (CLI) upgrade only when you have installed your Magento 2 by using the Composer or the Zip file from the official Magento website. CLI upgrade won’t work if you have cloned your Magento 2 store from GIT repository.
Follow these steps and commands to upgrade your Magento 2:
1. You will need the full file system access to do this upgrade. If you have the full file system ownership, then, first of all, connect to your web server via SSH.
2. Now login to your Magento 2 server using any SSH client. You can use the Putty SSH client here.
3. After establishing the SSH connection, Navigate to your Magento 2 root directory.
4. Now, run the following command:
NOTE: Here you can change the version number accordingly. For example, if you want to upgrade the Magento 2.0.x version, then change the edition accordingly.
5. Now, run this command:
NOTE: If you are prompted for authentication then you need to enter your magento.repo authentication keys after running the above command.
6. Now, run these three commands in the same order:
rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/*
php bin/magento cache:clean
php bin/magento cache:flush
NOTE: If you are using the Magento file system Cache storage then go to the next step. Otherwise, if you are using other Cache storage like Memcached, Varnish, and Redis then you will need to clear the cache manually for them.
7. Now, Run the following commands:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
8. Check the new version number using the following command:
php bin/magento –version
9. You can also verify the version number by going to your Magento 2 Admin Panel and refreshing the window. To check if you have successfully completed the update, see the Magento 2 version number at bottom right corner of the page. If there is any error, try clearing the cache again after resetting the file permission.
We have completed the Magento 2 update here. There are various other methods to update your Magento 2 store as well. However, this method is one of the quickest ones and saves a lot of time. Do let us know if you need any assistance in the update or searching for Magento and Magento 2 extensions. We have a pretty good collection of that.
You Might Also Like: