How to upgrade Magento 2.x via CLI

We can upgrade Magento 2.x via Command-Line Interface (CLI), but I have to remind again that you should backup all your website files before go ahead.

Upgrade Magento 2.x by command

Please back up your composer.json file before continuing.

The followed command will upgrade composer.json file:

composer require magento/product-community-edition 2.1.2 --no-update

Note: As 2.1.2 means the latest Magento version, so the numbers can be changed accordingly.

The followed command could upgrade the files:

composer update

Note: It will ask for authentication keys. For more information, visit this link.

Then execute the followed commands one by one:

rm -rf var/di var/generation

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento cache:clean

php bin/magento cache:flush

php bin/magento indexer:reindex

You may also like

1 Response Comment

  • seanmalJuly 8, 2018 at 6:08 am

    One can upgrade magento 2 using the two basic methods, one is from admin panel and other is using composer.


Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.