After creating our video about upgrading Magento 2 via the web wizard we received numerous requests to provide instructions on how to upgrade with SSH as well.
First, create a backup. This can be done either with Magento 2 commands via SSH, through the Magento 2 Administrative Backup Wizard, or manually using either your hosting providers control panel or directly through SSH.
Now that your system is backed-up it’s time to upgrade! Open a connection to your server via SSH and navigate to the root of your Magento 2 installation then run the following commands.
Put the store in maintenance mode
bin/magento maintenance:enable
Use composer to retrieve the desired Magento 2 release. In this example we are upgrading to version 2.2.2 this can be changed to any version beyond the one currently installed simply by adjusting the version prior to the –no-update command.
composer require magento/product-community-edition 2.2.2 --no-update
Use composer to retrieve the required dependencies for the Magento 2 update.
composer update
Delete all caching and pre-generated content from the previous store version.
rm -rf var/cache/* rm -rf var/page_cache/* rm -rf var/generation/*
Make bin/magento executable.
chmod +x bin/magento
Run the Magento 2 update script.
bin/magento setup:upgrade
Take Magento 2 out of maintenance mode.
bin/magento maintenance:disable
Your Magento 2 store has now been updated.
The full series of commands in order are listed below.
bin/magento maintenance:enable composer require magento/product-community-edition 2.2.2 --no-update composer update rm -rf var/cache/* rm -rf var/page_cache/* rm -rf var/generation/* chmod +x bin/magento bin/magento setup:upgrade bin/magento maintenance:disable