In this guide, we will explain how to upgrade your Magento version from Magento 2.0.x to Magento 2.1.x – 2.2.x using Command-Line Interface (CLI). Please keep in mind that this upgrade supports a fresh installation of Magento 2, so it is not recommended to apply this method to your live store. After the upgrade, you can migrate your data from the old Magento 2 store to the newly upgraded Magento 2.1.x – 2.2.x store.

How to Upgrade Magento 2 via CLI in Cloudways

Step 1: Access Your Server via SSH

You need to connect your server via SSH. You can follow this tutorial on how to connect your server via SSH.

Step 2: Navigate to the Magento 2 Root Directory

Once your SSH connection is up, you will need to move to your target application folder. In that application folder, you will find the public_html folder which is the root directory of Magento 2.

Step 3: Upgrade Commands

Please follow the same order and use the commands listed below:

composer require magento/product-community-edition 2.x.x --no-update

Important

As 2.2.x is the latest series, these numbers can be changed accordingly.

composer update

Important

It will ask for repo.magento.com authentication keys. For more information, visit this link.

rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/*
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?