3 Easy Ways to Upgrade Magento 2 to the Latest Version

3 Easy Ways to Upgrade Magento 2 to the Latest Version

Upgrading your Magento 2 store to the latest version will equip it with the newest features and improved security. It is important that you keep your store updated as otherwise; it will not only miss important features but will be an easy target for hackers.

In this article, we will cover all the 3 methods and the steps required in each method to upgrade your Magento 2 store. Before we do that, let’s see some pre-upgrade tasks. These tasks will ensure that the upgrade process goes smoothly and if in case something goes wrong, you have a way to recover it.

Magento 2 Pre-Upgrade Tasks

  • Enable Maintenance Mode: If you don’t want anyone to use your store while the upgrade process is on, enable maintenance mode. If you don’t prefer it, upgrade at a time when there is minimum traffic. Enable maintenance mode using the command below.
 
bin/magento maintenance:enable
  • Magento Backup: It is always recommended that you run a full Magento backup before making major changes. You can do this by running the following command.
 
bin/magento setup:backup --code --media --db

This will backup the System Code, Media Files and Database. If something goes wrong and does not let you proceed further, you can revert back to the old version.

  • Make Note of the Version Changes: Whatever version you are upgrading your store to, it’s important to carefully read its release notes for the changes made in that version.

3 Ways to Upgrade Your Magento 2 Store to the Latest Version

Following are the 3 ways using which you can upgrade Magento

  • Using Web Setup Wizard
  • Using Composer
  • Uploading the Latest Version Manually

Method 1: Upgrade Magento 2 Using Web Setup Wizard

If you are opting for this option, make sure you have a Magento account and your Public & Private Keys generated. The way you find these keys is by logging into your Magento account and going to Marketplace. Click on My Access Keys.

Remember, you must use the same authentication keys you used to install the Magento software.

  • Login to Magento backend as user with full permission.
  • Navigate to System -> Tools -> Web Setup Wizard
  • Click System Upgrade
  • Enter your Public & Private keys
  • Click Submit

It will now check for all new versions on your store.

Now you are on the system upgrade. The first thing you want to do is select the latest Magento 2 version from the Magento Core Components dropdown. You can also upgrade other components at the same time. Recommended is to keep it to No.

Click Next to go to the Readiness Check which will check your PHP versions, extensions, file permissions, etc.

If you get errors in the Readiness Check, you can upgrade your PHP version, check for 2.3.x System requirements or setup the cron job depending upon the error message. Once everything is ok, click Next to move over to Create Backup. Before you click on Create Backup, make sure you have sufficient storage on your server.

Upon successful upgrade, you will see the following screen.

Method 2: Upgrade Using Magento Composer

The second way to do Magento upgrade is to use composer via command line. For this, you need SSH access to connect to your web server and execute commands. Following is the workaround.

  • Login to your Magento 2 web server using SSH details.
  • Navigate to your Magento 2 root directory i.e. cd ~ /public_html.
  • Now run the following command to upgrade to the latest version
 
composer require magento/product-community-edition {version} –-no-update"

where {version} is the latest Magento version you want to upgrade to.

Now run the following command to start the update process.

 
composer update

Successful completion of the above command will upgrade your Magento version and you are ready to start running the new version. Running the following commands will clear the old cache.

 
rm-rf var/di var/generation

php bin/magento cache:clean

php bin/magento cache:flush

The following commands will update the database schema, run the compiler, deploy static content, and reindex the data respectively.

 
php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy
	
php bin/magento indexer:reindex

That’s all you need to do to upgrade your Magento 2 version using composer. If you want to check the version you have just upgraded to, the following command will do this. You can also check it at the bottom right corner of your Magento 2 Admin panel.

 
php bin/magento --version

Method 3. Upload the Latest Version Manually

This method is the simplest of all the three methods and suits inexperienced or newbie’s.

Download the latest/required version from the official Magento website. Unzip the downloaded file in the Magento 2 root folder. This will override the old files with the new ones.

Now, simply run the following commands in SSH console one by one to upgrade, update database schema, and flush cache.

 
php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

php bin/magento cache:clean

php bin/magento indexer:reindex

Conclusion:

As you saw, there are more than one ways to upgrade your Magento 2 installation. It’s all about your choice to opt for a particular method. For example, the setup wizard method is easier and good for people who are not comfortable with command line.

Should you have any questions or run into any errors? Do contact our Magento 2 upgrade team. Want to switch to Magento 2, we also offer Magento 2 migration service.