- We can upgrade Magento in two ways and they are as follows.
- Upgrade via Backend Admin Panel
- Upgrade using Composer
Before we do anything, just go ahead and backup your store so just in case anything goes south we can easily restore it and revert back to working version. We’ll need to backup the codebase and the database, I would suggest you should back up the following folders & files from Magento root directory :
- app,vendor,databasefile.sql,composer.json,composer.lock, and .htaccess
- Upgrade via Backend Admin Panel
- Login to the Magento Admin as an administrator.
- Click System > Tools > Web Setup Wizard.
- Click System Upgrade.
- Enter Public, Private access keys tokens and you’re good to go
- For more Info follow the link: Upgrade Via Admin
- Upgrade using Composer
Open the terminal and hit following commands step by step.
- php bin/magento maintenance:enable :
- In case your website is live in production mode then this command suspends frontend temporarily and gives the following message to users. “The site is undergoing through maintenance please try later ”
- composer require Magento/product-community-edition 2.3.1 –no-update
- This will add the new Magento 2.3 dependencies to your composer file.
- Please note that we are using composer command here so prerequisites are to have composer installed on your system.
- You can check the composer installed or not using the following command
- composer list
- If not installed please follow the link to install: Download Composer
- composer update
- This command tells the composer to install and update the new dependencies
- rm -rf var/cache/
- rm -rf var/page_cache/
- rm -rf generated/
- chmod +x bin/magento
- php bin/magento setup:upgrade
- php bin/magento setup:static-content:deploy
- php bin/magento maintenance:disable
Congratulations! Your store should be now upgraded to Magento 2.3.1.
For more reference follow the link: Upgrade Using CLI
- In case if you face page not found error (404), there are high chances of having issues with the .htaccess file, So just restore backed up .htaccess with the current one and you’re good to go.
- In case if you face internal server error (500), there are high chances of permission issues so just hit the following command :
- sudo chmod -R 777 pub var generated (for root(sudo) user) .
- chmod -R 777 pub var generated (for other users).