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

How to Update Magento 2 Using the 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?”

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:

  • Make sure that you’ve installed a supported search engine
  • Review the system requirement for the Magento version you’re upgrading and update the software.
  • Verify if the cron jobs are installed and enabled
  • Verify if your file system permissions are set properly
  • Make sure to set the pub/ directory root
  • 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. 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

  • 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. Verify the work

  • 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

Even after updating Magento 2, if you’re still facing any issues related to performance or whatsoever, don’t worry; we got your back!

Our team of Magento experts at HumCommerce will run a complete site audit and identify all the major threats and vulnerabilities in your website, giving you ideal suggestions. It’s upon you how or whether you’ll fix them. But if you decide to, our team of experts will solve them within the promised time.



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

Share the post

How to Update Magento 2 Using the Command Line

×

Subscribe to Magento 2 Ecommerce

Get updates delivered right to your inbox!

Thank you for your subscription

×