Posted in: Magento 2, SSH

Updating Magento 2 to a New Sub-Version

Updating Magento 2 is very simple however, I would like to stress the importance of backing up your database BEFORE running any upgrade. I’d also like to HIGHLY suggest you do NOT do this on a production site until you’ve tested either locally or on a dev/staging environment. You will need to take a backup of the database just in case you need to roll back the upgrade for whatever reason. Also, document which version you are currently on, for rollback purposes as well.

Okay, so the first thing you need to do is to login to your server via SSH and cd to your Magento installation root.
Run the following, make sure you change the version number (2.2.3) to the version you want to upgrade to. At this time the latest stable release is 2.2.3, so I will be using that in the examples.

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

Next you are going to want to update composer packages by running:
composer update

Once this is finished you need to clear your var and static files:
rm -rf var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/* generated/*

Next go through the compilation and deployment process:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:flush
php bin/magento cache:clean

If you are using Redis and/or Varnish, be sure to flush those as well.
That’s it. You should now have an updated version of Magento 2!

Have your say