Upgrading Magento 2

Upgrading Magento 1 systems was a tedious task involving installing a vanilla instance, copying over custom theme and application code and upgrading the database. Upgrading Magento 2 is now a lot simpler with the application code managed by composer.

In the Admin

In the admin area, Magento offers the ability to upgrade the system, located under System -> Web Setup Wizard.

Then choose System Upgrade.

Upgrading Magento 2

If you haven’t entered them already, Magento will ask you to enter your access keys to authenticate you.

Upgrading Magento 2

If you do not have the access keys to hand, you can generate a pair within your Magento Marketplace account.

Upgrading Magento 2

After successful authentication, Magento will check for the most recent version of Magento, and allow you to choose to upgrade to it.

Upgrading Magento 2

If you are unsure of the Magento version you are currently version, Magento adds the version number at the bottom of the admin area when you first log in.

Proceed through the next steps to complete the upgrade process. Note that Magento will expect you to have your cron configured correctly in order for the application to identify your current PHP version. Ensure that you have set up cron properly and ensure your application’s file permissions are set to the correct web server user and file system owner.

Using Composer

There is also an option to upgrade the Magento application using the command line.

To prevent users from accessing your site whilst the upgrade takes place, it is recommended that you put your store in maintenance mode.

Ensure you have cd‘d into your Magento root directory and run the following composer commands.

For example, to upgrade to Magento CE version 2.1.5, enter:

$ composer require magento/product-community-edition 2.1.5 --no-update
$ composer update

The first command will update Magento’s composer.json file and the second command will load the composer repositories and update dependencies.

To upgrade to Magento EE version 2.1.5, enter:

$ composer require magento/product-enterprise-edition 2.1.5 --no-update
$ composer update

After successfully running the commands, Magento recommends you clear your cache and update the Magento indexes. You can do it by running the following set of commands.

$ rm -rf var/di var/generation
$ /path/to/your/php bin/magento cache:clean
$ /path/to/your/php bin/magento cache:flush
$ /path/to/your/php bin/magento setup:upgrade
$ /path/to/your/php bin/magento setup:di:compile
$ /path/to/your/php bin/magento indexer:reindex

Note: This article is based on Magento CE version 2.1.