How To Upgrade Magento 2 Website To Latest Version

How To Upgrade Magento 2 Website To Latest Version

Magento 2 is the next-generation eCommerce platform with lots of benefits over the older version of Magento 1.

Since you are already running your webshop on Magento 2, it is important that you keep it secure and up to date by upgrading your Magento 2 set up to the latest stable version.

And to make it easy for you, Our Magento 2 experts have prepared this:

A Guide to Update Your Magento 2 Installation to Latest Version

Backup

Before you start working on the version update, the first thing you want to do is take a full backup of your Magento store. Take a backup of store files and database using your server’s control panel or SSH otherwise consult your hosting provider for help. You can restore your webshop using the backup if any of the steps break your website or causes data loss.

Disable Cache

Make sure that the Magento cache is disabled during the version update process. This will save you a lot of time.

To disable cache go to Admin → System → Cache Management → select all cache types and disable them.

Pre-update Checklist

We recommend you follow the below checklist before doing the version update to make this process hassle-free and less stressful.

  • Check for the available versions of Magento 2 and choose the most secure, recent, and stable version to update your installation.
  • Once you have identified the version, Carefully read the notes to get familiarized with the changes made to that version.
  • Make note of any customizations or overrides you may have done on your webshop for you to check and ensure all the functionality is working as expected for your store after the upgrade is done.
  • Create a staging website or environment where you can first try the update and check the compatibility of your server as well because there might be some changes needed in server configurations for the new version.
  • Keep note of all the logs, messages, and reports which are shown during the version update so you can keep track of any modifications you may have done during that step to install other libraries or updates on the server or modules.
  • The last thing is to decide on the time to do the version update on the live website by following all the steps again. After the version is updated on the staging site successfully and you have ensured everything is working as expected without any issues or conflicts then schedule the update on the live web shop when there is no traffic on your website.

Now that we have prepared for the version update, follow the instructions below.

There are 2 Ways to Upgrade Magento 2 Version

    • 1. Web Setup Wizard
    • 2. Composer via Command Line

1. Web Setup Wizard

    • Before updating your Magento 2 store with this option, make sure you have a Magento account and have a keypair generated in your account.
    • Here’s how you can set the key pair. Go to Admin → System → Web Setup Wizard→System Config and add the public and private keys there and click Submit.

magento2-system-upgrade-system-config

    • Now go to Admin → System → Web Setup Wizard→ System Upgrade. Select the latest and stable Magento 2 version here and keep Other Components set to No because updating them with Magento may cause issues.

magento-system-upgrade

    • Next, you will start the ‘Readiness check’. If your system and server are compatible with the selected version of Magento 2 then you are all good to go otherwise you have to resolve the issues first which are presented there before moving to the next step. Make sure you have cron jobs running or refer to the official Magento Documentation for the server compatibility check.
    • Click Next once the Readiness Check is passed and Create a backup by checking all the boxes (Code, Media, Database) and click Create a backup. This may take quite some time based on the size of your store and database files.
    • Once the database backup is created, click Upgrade to finish the version upgrade.
    • If your Magento is updated to the latest version then you will see the below screen with confirmation for a successful version update.

magento2 installation completed

  • After you have to upgrade your Magento 2 store version, it is recommended to remove the setup files because they are publicly accessible and causes security breach. Remove this directory from your hosting account or FTP or SSH /data/web/magento2/setup. If you face any difficulty during the process, Contact your Magento 2 development company to assist.

2. Composer via Command Line

You can also do Magento 2 version update using Composer from Command Line in case the Web Setup Wizard does not let you do the update due to any conflicts, extensions, or readiness checks required.

    • For this, you will need SSH access to your server to execute commands via the command line. But make sure you are not logged in as a root user but a normal user or apache user or whichever user is shown as the owner of the Magento directory otherwise it will cause conflicts.
    • Login with SSH details on the server and go to your Magento root directory and run the below command where {version} is the latest version which you want to update to, for example, 2.2.5:
composer require magento/product-community-edition {version} –-no-update
    • This will specify in composer.json which version you want to update and after that, you have to run this command to start the version update process:
composer update
    • Once the above command is successfully completed then you are almost ready to get the new version running. Now that everything is installed or updated then let’s clear the old codepool and cache with the below commands one by one:
rm-rf var/di var/generation
php bin/magento cache:clean
php bin/magento cache:flush
    • Now its time to update the database schema and data as per the new version updates with the below command:
php bin/magento setup:upgrade
    • Next, we need to run the below command to run the compiler which will do a compilation of the code and generate codepool, repositories, service data attribution, and validate dependencies:
php bin/magento setup:di:compile
    • And after that you have to run another command to deploy the theme files:
php bin/magento setup:static-content:deploy
    • And at last, to reindex the data in the database we need to run the command:
php bin/magento indexer:reindex
    • Now we are all done with upgrading Magento 2 to the latest version and it’s time to check what is the current Magento 2 version with the below command:
php bin/magento--version

Before you sign off, make sure the directory permissions are correct and enable the cache.

To enable cache go to Admin → System → Cache Management → select all cache types and enable them

If you have any other questions about upgrading your Magento 2 set up to the latest version, Please feel free to contact our Magento 2 migration service team. They are happy to help you out.

Parth Patel, a skilled E-commerce Consultant and co-founder of Icecube Digital, dedicates his time to producing straightforward yet invaluable content. With a sharp attention to detail and a passion for innovation, Parth focuses on Magento, WordPress, Shopify, and other platforms in his commitment to advancing e-commerce solutions.

Leave a Reply