How to Upgrade Magento Version from 2.3.X to 2.4.0?
Magento 2.4.0 is released. As per release notes, it contains 98 new features, 50 security changes, support of 2FA in admin by default, and PHP 7.4 support. As a store owner or as a developer, you should never miss this crucial upgrade. Today we will see step by step guide to upgrade Magento version from 2.3.x to 2.4.0.
Preparing Your Site for Upgrade
- Make sure your server is configured to work with PHP 7.4. Magento 2.4.0 officially support only PHP 7.4. Though you can install Magento 2.4.0 with PHP 7.3 but it is not tested. So it is recommended to use PHP 7.4 with Magento 2.4.0. You can check your PHP version by running below command
- Make sure your composer is pointing to correct PHP version 7.4. You can check your composer’s PHP version by running below command
composer -vvv about
- Make sure your server has installed and configured Elasticsearch 7.6.x. Magento 2.4.0 does not support MySQL as a catalog search engine. You can check your Elasticsearch version by running below command
curl -XGET ‘http://localhost:9200’
curl -XGET ‘http://YOURDOMAIN:9200’
- Take a code and database backup. Many developers are already managing their code in git. For them, an only database backup is important as they can revert the code from git if the upgrade goes wrong.
Upgrade Magento Version from 2.3.X to 2.4.0
Step 1: If you are directly performing the upgrade on your live site then first put your site into maintenance mode by running below command.
php bin/magento maintenance:enable
Step 2: If you are performing the upgrade on your local system then you can skip step 1 and start with step 2.
Take a backup of the
cp composer.json composer.json.bak
Step 3: Install the Composer update plugin
composer require magento/composer-root-update-plugin=~1.0 --no-update composer update
Step 4: Update composer.json file with latest version. In our case, it is Magento Version 2.4.0. Navigate to your Magento 2 installation root path and run below command
composer require magento/product-community-edition=2.4.0 --no-update
Step 5: Run below command
This command will take some time to finish. This command will actually download all the required packages and upgrade your Magento version from 2.3.x to 2.4.0. After this command finish, run below commands
Step 6: Clear cache and regenerate code.
php bin/magento cache:clean rm -rf var/cache/* rm -rf var/page_cache/* rm -rf generated/code/* php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f
Step 7: Disable maintenance mode
php bin/magento maintenance:disable