The Ultimate Guide to Upgrade Magento 2
Magento 2 is the eCommerce software and platform that is trusted by the world’s leading brands. The undeniable benefits of Magento 2 make it a preferred eCommerce platform. Some typical benefits that should be named are a quality extension ecosystem and highly-supported eCommerce features.
The post is researched by Mageplaza’s specialists to guide the user how to upgrade Magento 2 version when using the command line & composer. Let’s follow this guide step by step.
4 Steps to update Magento 2
- Step 1: Backup your store
- Step 2: Turn on maintenance mode
- Step 3: Upgrade to Magento 2
- Step 4: Check the current Magento 2’s version
Step 1: Backup your store
Creating backups for your Magento 2 site is so urgent and necessary that you can protect all data from the disappearance through Backup Management if there is any change or break on the site. Follow this guide to backup your Magento 2 store.
Step 2: 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 3: Upgrade to Magento 2
In this case, I will upgrade to Magento version 2.2.1
. See latest releases at Download page, Github releases
Step 3.1 Pull package
Using the following command on terminal/command-prompt
firstly:
composer require magento/product-community-edition 2.2.1 --no-update
composer update
You may be asked for username and password like this:
To generate Public/Private Key pair please read this
Step 3.2 Flush cache
Now time to remove cache, generation. Run the following command line at 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 3.3 Run Upgrade Magento
Run upgrade module, database schema
php bin/magento setup:upgrade
Step 3.4 Run complie, 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 the permission issues, remember to insert
sudo
at the beginning of every command likesudo composer update
.
Step 3.5 Disable maintenance mode
You have turn on maintenance mode in the step 2, now you have to turn it off. Run the following command line to turn it off:
php bin/magento maintenance:disable
Step 4: 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 show the cache write permission error, please add the following command to give write permission to pub and var directories:
chmod -R 777 pub var
FAQs
Q: 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/*
Upgrade Magento 2 Service
Mageplaza offer Upgrade to the latest Magento 2 version, please contact us for further information.
That is all things you will use to upgrade/update Magento 2’s version via command line & composer. Thanks for your reading and please comment below if there is any trouble in that.
Enjoyed the tutorial? Spread it to your friends!
Sam Thomas
CEO and Founder of Mageplaza. Pursueing a simple and healthy lifestyle. A friend, a husband and a dad of two children, a trainer and an influencer wannabe. He is a big fan of sports and travel, also.
Featured Extensions
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.2.x, 2.3.x, 2.4.x