Holt DevOps News

Update Magento 2 via CLI

News Categories: MagentoServer HelpTech

This article was published on: 06/26/21 6:40 AM

Update Magento 2 via CLI

First thing is to back up the server / data before driving in

 

Put the site in maintenance mode

bin/magento maintenance:enable

 

If you do not have composer installed, no would be a good time 🙂 – To install the plugin:

composer require magento/composer-root-update-plugin=~1.0 --no-update

 

If the composer runs out of memory you can try

COMPOSER_MEMORY_LIMIT=-1 composer update

 

We now need to make a backup of the composer json file by running this command

cp composer.json composer.json.bak

 

We now need to install the version of magento we are updating too, in our case its 2.4 so we run this command

composer require magento/product-community-edition=2.4.0 --no-update

 

To see the full list of magento 2.4 versions available we can use the following

composer show magento/product-community-edition 2.4.* --all | grep -m 1 versions

 

Right, lets get the update installed and fingers crossed there isnt any minor issues.

composer update

Remember if the composer runs out of memory use the following command to overwrite this: COMPOSER_MEMORY_LIMIT=-1 composer update

 

Allow the the update to run through all the checks and then updates – keep an eye out for anything that fails.

 

Once the composer has finished updating without any issues we can then proceed to the clean up the install and start running the new Magento 2 version:

 

rm -rf var/cache/*

rm -rf var/page_cache/*

rm -rf generated/code/*

 

Next to update the database schema to work with the new M2 version

bin/magento setup:upgrade

If the following error pops up like the composer php error we can run
=php -d memory_limit=-1 bin/magento setup:upgrade

If you have the elasticsearch error you can follow this guide to install: https://devdocs.magento.com/guides/v2.4/install-gde/prereq/elasticsearch.html

Also checkout the official elasticsearch install – this is for Linux servers: https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html#rpm-repo

bin/magento maintenance:disable

and relax, well done you have completed the magento 2.3 to 2.4 upgrade 🙂

If your frontend is still showing the error you can try and clear all the cache files again as this has happened to us a few times.

Also if you do not receive the 2 factor email and you are locked out of the admin panel please run the following command.

 

bin/magento module:disable Magento_TwoFactorAuth

or

php -d memory_limit=-1  bin/magento module:disable Magento_TwoFactorAuth

 

This is an epic footer, don't you think?

We’re Hardcore Experts in Cutting-edge Design & Development Technologies - Worldwide accreditation from leading digital platform providers

Web Development Agency Manchester

The Barn
Woolden Road
Manchester
M44 5JX


Stalk Us On Social

Web Development Agency London

71-75 Shelton Street
Covent Garden
London
WC2H 9JQ


Let's hook up

hello@holtdevops.com

0161 676 8989

Copyright 2021 Holt DevOps Ltd - White Label Web Development Digital Agency | 13127888 Registered in England and Wales | Privacy Policy

Ready to work with us?

Drop us your details and we will arrange a social distanced meet & greet or video chat so you can see our beautiful faces.

    Name*

    Email*

    Telephone