Reading Time: 2 minutes

Magento 2 is the software and E-Commerce platform trusted by the world’s leading brands. The undeniable advantages of Magento 2 make it one of the most used platforms. Some typical benefits that should be named are an ecosystem of quality extensions and highly supported E-Commerce features.

In this post, we will therefore see how to update Magento 2, so that you can be completely autonomous in this.

Step 1: Back up your store

Creating backups for your Magento 2 site is a fundamental element because it allows you to protect all data through the Backup Manager, in case of changes or interruptions on the site.

Step 2: Activate maintenance mode

Once the backup is done, you should put your store in maintenance mode while updating. To enable maintenance mode:

php bin/magento maintenance:enable

This will create a new var / .maintenance.flag file. If you can’t disable maintenance mode, you can remove this file

Step 3: Upgrade to Magento 2

In this case, we will do an update to Magento version 2.2.1. See the latest versions on the Github download page .

Step 3.1 Pull package

First using the following command on the terminal / command-prompt:

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

Username and password might be requested like so:

aggiorna magento

Step 3.2 Clear the cache

Now it’s time to remove the cache, build. Run the following command line in the root folder:

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*


You can install Memcached, Redis cache…, you should empty those caches manually.

Step 3.3 Upgrade Magento

Run update module, database schema

php bin/magento setup:upgrade

Step 3.4 Reindex

You should compile and re-index for better performance after the upgrade

php bin/magento setup:di:compile
php bin/magento indexer:reindex

In Ubuntu / Debian Linux, when you encounter authorization problems, remember to insert sudo at the beginning of each command as sudo composer update.

Step 3.5 Disable Maintenance Mode

You turned on maintenance mode in step 2, now you need to turn it off. Run the following command line to disable it:

php bin/magento maintenance:disable

Step 4: Check the current version of Magento 2

After that, you can check the Magento 2 version by running the command.

php bin/magento --version

If the system shows the cache write permission error, add the following command to grant write permission to the pub and var directories:

chmod -R 777 pub var

Frontend login problems after update: how to fix

You may receive this message: “We’re sorry, an error occurred while generating this email”.

This is due to the read-write permissions for the web server. Run the following command to fix 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

Refresh the cache again.

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*

Problem solved!
You have now updated your Magento!


Free 30-days trial Hosting magento Fast, Secure and Optimized

Switch to Bhoost with 30 days free and migration included

Free 30-days trial