Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Update Magento 2 Using Command Line

Magento 2 is one of the leading eCommerce software platforms, widely used by famous brands. The number of things that you have control over in Magento is insane. There are plenty of things that you could tweak according to your convenience. Since there are tons of things in Magento, there are many questions and doubts in the users’ minds. One of the questions the Magento users have is “how to update Magento 2?”

Magento 2 update using the command line

Updating Magento 2 to the latest version may not be everyone’s cup of tea, especially if you’re someone who’s not familiar with coding. However, you can Upgrade to the latest version of Magento 2 through the command line. So, don’t worry if you’re not familiar with coding. This article teaches you how to update Magneto 2 by following a few simple steps.

Before we get into the steps, remember that you can only upgrade Adobe Commerce/Magento Open Source using the command line had you installed it by:

  1. Composer create-project command after downloading metapackage.
  2. Compressed archive.

Now that you’re aware of that, shall we begin?

Steps to update Magento 2 using the command line

1. Complete the upgrade prerequisites before you begin:

  • First, review the system requirement for the Magento version you’re upgrading.
  • Next, complete the list of upgrade prerequisites.
  • Now, install the composer update plugin.
    • Follow this to install the plugin:
      composer require magento/composer-root-update-plugin ~2.0 --no-update
    • Then, update the dependencies:
      composer update

2. Turn on maintenance mode and manage packages

  • Before the upgrade process, first, enable the maintenance mode.
    bin/magento maintenance:enable
  • Backup your store by creating the composer.json backup file.
    cp composer.json composer.json.bak
  • Next, add or remove the package you want, based on your convenience.
    composer remove magento/product-community-edition --no-update
  • State the upgraded version’s name and edition in the upgrade command. Example:
    • Magento Open Source:
      composer require magento/product-community-edition=2.4.4 --no-update
    • Adobe Commerce:
      composer require magento/product-enterprise-edition=2.4.4 --no-update

3. Updating meta details

  • Update the “name”, “version”, and “description” fields in the composer.json file as per your needs.
  • Then, apply the composer update.
    composer update
  • Next, clear the subdirectories var/ and generated/
    rm -rf var/cache/*
    rm -rf var/page_cache/*
    rm -rf generated/code/*
  • Now, update the data and schema database
    bin/magento setup:upgrade
  • Switch off the maintenance mode:
    bin/magento maintenance:disable
  • You can restart Varnish if you use it for page caching.
    service varnish restart

4. Check the update

  • Open your website link in a browser to verify if the upgrade happened successfully. On an unsuccessful upgrade, your website won’t load properly.
  • If you’re facing the “We’re sorry, an error has occurred while generating this email” error message, here are a few things you can try:
    • Reset the file system permissions and ownership 
    • Clear the below directories:
      1. var/cache/
      2. var/page_cache/
      3. generated/code/
    • Recheck your website

If you’re still facing lag or performance issues after updating Magento 2, you’ll be required to optimize your website for stability. A Magento performance audit will help you identify all the problems responsible for the issue and provides a report with ideal suggestions to fix those problems.



This post first appeared on Magento 2 Ecommerce, please read the originial post: here

Share the post

How to Update Magento 2 Using Command Line

×

Subscribe to Magento 2 Ecommerce

Get updates delivered right to your inbox!

Thank you for your subscription

×