Shopping cart

The Ultimate Guide to Upgrade Magento 2

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.

Overview

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:

authentication keys 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 like sudo 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 ugprading?

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.





Meet Mageplaza at Meet Magento Asia

Enjoyed the tutorial? Spread it to your friends!

magento-2-tutorial
upgrade
update
via
command
line
composer

Comments for The Ultimate Guide to Upgrade Magento 2

Please leave comments if you have any questions, feedbacks.

Module Development

We recommend:

You also may like these Magento 2 Extensions

One Step Checkout

$199
69 reviews

Gift Card

$199
no review

People also searched for:

  • magento 2 upgrade update via command line composer
  • magento 2 upgrade composer
  • magento 2 latest version
  • upgrade magento 2 command line
  • magento 2.1 upgrade
  • magento 2 upgrade command
  • magento 2.1.2 upgrade
  • sorry we can't take that action right now. magento 2 upgrade
  • magento 2 system upgrade
  • How to Upgrade via Command Line in Magento 2
  • upgrade update via command line in magento 2
  • update via command line in magento 2
  • upgrade via command line in magento 2