we caboodle News

Update Magento 2 via CLI

News Categories: MagentoServer HelpTech

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

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

 

we caboodle - full service agency team

Ready to Start?

we are driven by the challenge of building a bespoke website for your business, improve SEO performance, fix UX/UI issues and streamline your branding across all social & paid channels.

Are you looking for a new, full service agency? contact us today for a free quotation or advice, and lets build something great, together!

let's
talk

    Name*

    Email*

    Telephone


    William Holt

    Meet Will

    I've been designing & developing websites for over 2 decades. my first project was built on Microsoft Frontpage, yes I go that far back!

    Speak to me direct regarding your next project or the benefits of switching your digital agency to Web Caboodle

    will@wecaboodle.com | 07368 229004 | LinkedIn Profile

    Web Design Manchester

    Studio 13
    Woolden Road
    Manchester


    Web Design London

    71-75 Shelton Street
    Covent Garden
    London


    let's connect

    hello@wecaboodle.com


    Copyright 2023 Web Caboodle - Web Design and Development Agency | We Website Design Ltd 13127888 Registered in England and Wales | Privacy Policy