Magento is one of the most adaptable ecommerce platforms, with thousands of businesses worldwide relying on it.
It is critical to keep your Magento 2 online store up to date. Magento 2 upgrades via software updates are provided regularly to increase performance, resolve issues in the current version, add new features, and improve the shop experience.
Performing a Magento 2 upgrade
Running outdated versions of Magento 2 can expose your store to security vulnerabilities and — in the worst-case scenario — lead to a store failure. As a result, it is critical to update Magento 2 to the most recent version. This article will guide you through the process of upgrading your Magento 2 store to the latest version.
Magento 2 upgrade to 2.4.5
You can go through the steps documented below to perform Magento 2 upgrade to 2.4.5. Refer to our Ultimate guide to each Magento version: What, why, and how to update blog article for a comparison of Magento 2 upgrade candidates by version number. If you have any questions about using the Nexcess Client Portal, you can see the helpful portal guide in our Nexcess Knowledge Base.
Step 1: Back up your Magento store
Backing up the Magento 2 store before the upgrade process is critical to avoid data loss if something goes wrong during the Magento 2 upgrade. You can follow the instructions in the Creating website backups from the Site Dashboard article to back up your Magento 2 store.
Step 2: Prepare the site for upgrade
Before starting a Magento 2 upgrade to the latest version, ensure your site runs a supported PHP version. You can find the PHP version supported by each Magento version on the Adobe page containing this important information. To find the current PHP version of your plan, navigate to the Management tab of your hosting plan with us in the Nexcess Client Portal.
2a. Make sure your composer is using the correct PHP version. To check your composer's PHP version, you can execute the following command:
]$ composer -vvv about
2b. You can use the composer2 command instead of the composer command if the Magento Composer is not set to local.
2c. All installations must be set to use Elasticsearch as the catalog search solution as of Magento 2.4. To find your Elasticsearch details, go to the Containers of your plan in the Nexcess Client Portal.
2d. To enable Elasticsearch for your Magento 2 store, refer to the article How to enable Elasticsearch for your Nexcess Cloud account.
2e. To configure your Magento 2 store to use Elasticsearch, refer to the article How to configure Magento 2 to use Elasticsearch.
Step 3: Turn on maintenance mode
While upgrading, you should set your Magento 2 store in maintenance mode. To turn on maintenance mode, execute the following command from the Magento root folder:
]$ php bin/magento maintenance:enable
It will make a new file called var/.maintenance.flag. You may delete this file if you cannot turn off maintenance mode.
Step 4: Back up the composer.json file
You can back up the composer.json file by executing the following command:
]$ cp composer.json composer.json.bak
Step 5: Install the Magento Composer update plugin
To install the Magento Composer update, you can execute the following commands.
]$ composer require magento/composer-root-update-plugin=~1.0 --no-update
]$ composer update
Step 6: Update the composer.json
You can execute the following command to update the composer.json to the latest version. You can replace the Magento version 2.4.5 as per your requirement:
]$ composer require magento/product-community-edition=2.4.5 --no-update
Step 7: Use the Magento Composer update command
To update the Magento Composer and download all the required packages, you can execute the following command:
]$ composer update
If you are facing issues with the Magento Composer while installing or upgrading, refer to the Magento Composer install and troubleshooting guide article. If you still need our assistance, please contact our Magento specialists.
Step 8: Clear the cache
⚠️ Warning! ⚠️
Please use the rm command with extreme caution. Misuse of the rm command can result in losing all vital data and irreversible system damage.
To clear the cache, you can execute the following commands from the Magento root folder:
]$ rm -rf <Magento_root_folder>/var/cache/*
]$ rm -rf <Magento_root_folder>/var/page_cache/*
]$ rm -rf <Magento_root_folder>/generated/code/*
]$ php bin/magento cache:clean
]$ php bin/magento cache:flush
Execute the Magento 2 upgrade command set
To upgrade the module, DB schema, and data, you can execute the Magento 2 upgrade command from the Magento root folder:
]$ php bin/magento setup:upgrade
After upgrading, you should compile and reindex to improve performance. You can execute the following commands to do the same:
]$ php bin/magento setup:di:compile
]$ php bin/magento indexer:reindex
To deploy static content, you can execute the following command:
]$ php bin/magento setup:static-content:deploy -f
Turn off maintenance mode
Once everything is completed, you can turn off maintenance mode by executing the following command from the Magento root folder:
]$ php bin/magento maintenance:disable
Magento 2 version check
To check the Magento 2 version, you can execute this command shown below from the Magento root folder:
]$ php bin/magento --version
If you are looking at how to install a fresh Magento 2.4.5-p1 for your Magento 2 store, you can refer to the article Magento security patch: installing Magento 2.4.5-p1.
Get more Magento tips from the Magento specialists at Nexcess
With the help of this article, you can easily comprehend and perform the Magento 2 upgrade.
PWA-readiness is built in
Nexcess is one of the only platforms to actively support new Magento Progressive Web Application (PWA) technologies. We integrate and create more implementation guides than any other host.
You can contact our Magento specialists for assistance if you encounter problems when conducting the Magento 2 upgrade.
You can also contact us to purchase an appropriate managed Magento hosting plan for your Magento 2 store and install a fresh Magento instance for the website.