How to Upgrade Magento 2 Version

  1. 1. Backup your magento 2 site

    Upgrading a Magento 2 site to a newer version is an important process that requires careful attention to ensure a smooth transition. To start, it's recommended to create a backup of your current site's composer.json file as a precautionary measure.

    cp composer.json composer.json.bk
  2. 2. Enable maintenance.

    Next, enabling maintenance mode ensures that your site is not accessible to visitors while the upgrade process is underway. Specific packages can be added or removed depending on your needs. In this case, the magento/product-community-edition package is being removed.

    bin/magento maintenance:enable
  3. 3. Add or remove specific packages based on your needs.

    composer remove magento/product-community-edition --no-update
  4. 4. Upgrade to Magento 2

    The upgrade process can begin by requiring the new Magento 2 version and updating it via composer. Once the upgrade is complete, it's important to clear out the cache and generated code directories. The database schema and data should then be updated using the appropriate Magento 2 command.

    composer require magento/product-community-edition 2.x.x --no-update
    composer update
  5. 5. After composer upgrade.

    After these steps have been completed, maintenance mode can be disabled, and the site can be tested thoroughly to ensure everything is working as expected. Finally, checking the current Magento 2 version confirms that the upgrade was successful.

  6. execute below command
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf generated/code/*
  1. Updating the database schema and data is an essential step when upgrading a Magento 2 site. This step ensures that the database is compatible with the new version of Magento 2 and that any necessary changes to the database structure are made.
  2. To update the database schema and data in Magento 2, you can use the command-line interface and run the following commands:
bin/magento setup:upgrade
  1. This command deploys the static view files to the appropriate directories so they can be served by the web server.
  2. Additionally, you may also need to deploy static view files and run the following command:
bin/magento setup:deploy:content -f
  1. This command disables maintenance mode and allows visitors to access the site again. Once maintenance mode is disabled, you should verify that the site is functioning properly and that there are no issues before making it live.
  2. To disable maintenance mode in Magento 2, you can use the command-line interface and run the following command:
bin/magento maintenance:disable
  1. This command displays the current version of Magento 2 that is installed on your server. The output will show the version number, edition, and any additional information related to the installation.

    To check the current version of Magento 2, you can use the command-line interface and run the following command:

php bin/magento --version

Copyright © 2013-present Magento, Inc. All rights reserved.