There are 3 Ways to Upgrade your Magento 2 Store:
- Using Composer, a terminal command line program.
- Web Setup Wizard in the admin dashboard
- Copy a fresh copy of M2 over the old installation.
1. Using Command-line Upgrade
1.1. Upgrade to Magento Open Source v2.2 without sample data
Step 1: First of all, connect to your web server via SSH. Using putty or any SSH client, log in to your Magento 2 server with full file system ownership.
Step 2: Once your SSH connection is established, you will need to navigate to your Magento 2 ROOT directory in the terminal using cd command
Step 3: Upgrade to Magento Open Source version 2.2.0
Upgrades to version 2.2 without sample data can fail because of an issue with the Magento composer-installer component. It doesn't correctly detect code changes and therefore doesn't update the cache and compiled code directories properly. As a result, fatal errors display during the upgrade.
Note that, you have to be in your Magento’s directory root while running the below commands.
To address the issue, you must apply a patch named MDVA-532.* from Magento.com, then transfer it to your Magento server.
You have to run the following commands:
composer require magento/product-community-edition 2.2.0
composer update
rm -rf var/di var/generation
php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy -f (for Magento 2.2.x)
php bin/magento cache:flush
php bin/magento setup:di:compile
php bin/magento indexer:reindex
Note: You have to be in your Magento's directory root while running the below commands. Replace product-community-edition 2.2.0 with the current version if there's a newer one.
After this is completed run the following code chain to update database schema and data.
php bin/magento setup:upgrade
Visit the homepage to see your updated Magento 2. If you get some errors, reset file permissions and ownership and then clean cache.
1.2. Upgrade to Magento Open Source v2.2 with sample data
These instructions apply to Magento Community Edition (CE) users only if all of the following are true:
- You have installed optional sample data
- You're upgrading to Magento 2.1 (including a Release Candidate) from any earlier version using the command line
To upgrade to Magento 2.1 sample data using the command line:
- Log in to your Magento server as, or switch to, the Magento file system owner.
- Change to the Magento installation directory.
- Back up your current composer.json:
cp composer.json composer.json.bak
- Upgrade the Magento software version using commands of the following format:
composer require <product> <version> --no-update
composer require <sample data="" module-1="">:<version> ...
Example for Magento Open Source:
composer require magento/product-community-edition 2.0.0 --no-update
composer require magento/module-bundle-sample-data:100.1.0 magento/module-widget-sample-data:100.1.0 magento/module-theme-sample-data:100.1.0 magento/module-catalog-sample-data:100.1.0 magento/module-customer-sample-data:100.1.0 magento/module-cms-sample-data:100.1.0 magento/module-catalog-rule-sample-data:100.1.0 magento/module-sales-rule-sample-data:100.1.0 magento/module-review-sample-data:100.1.0 magento/module-tax-sample-data:100.1.0 magento/module-sales-sample-data:100.1.0 magento/module-grouped-product-sample-data:100.1.0 magento/module-downloadable-sample-data:100.1.0 magento/module-msrp-sample-data:100.1.0 magento/module-configurable-sample-data:100.1.0 magento/module-product-links-sample-data:100.1.0 magento/module-wishlist-sample-data:100.1.0 magento/module-swatches-sample-data:100.1.0 magento/sample-data-media:100.1.0 magento/module-offline-shipping-sample-data:100.1.0 --no-update
- Update dependencies:
composer update
If prompted, enter your authentication keys. Wait for dependencies to update.
- When finished, reset file system permissions. Then run:
php bin/magento setup:upgrade
2. Using the Web Setup Wizard in the Admin Dashboard (Run System Upgrade)
Step 1: Run System Upgrade
- Log in to the Magento Admin as an administrator.
- Click System > Tools > Web Setup Wizard >> Click System Upgrade
-
You need to enter your authentication keys in the provided fields.
-
Once you submitted successfully the Public Key and Private Key, you will be navigated to System Upgrade page.
- Magento Core Components list: Choose the core component version which you want to upgrade. For each third-party component: If you do want to upgrade it, set Upgrade to Yes and click the version from the Update Version list. For more information, please refer here
Step 2: Readiness check
If everything is green go to next step. If not, make sure you have cron jobs running, or refer to the official Magento documentation
Step 3: Create Backup
After you pass all readiness checks, you can back up following this guide
Step 4: Finish The Upgrade
Once you are ready with backup, click on next. To complete the upgrade, click Upgrade. If the upgrade is successful, a page similar to the following displays.
After you finish your upgrade, errors might display. Please find the solution on the official Magento documentation website
You will see the upgraded version of Magento but you will need to run these commands to finish.
php bin/magento setup:static-content:deploy php bin/magento cache:clean php bin/magento indexer:reindex
3. Download the latest version manually copy/paste
Upgrade this way if the previous two failed for whatever reason.
- Download the latest Magento 2 off the official website. Unzip it in your magento main folder. That will overwrite the core files with the new ones.
- Then run:
php bin/magento setup:upgrade
and
php bin/magento deploy:mode:set production
- That will upgrade database, compile and deploy static content. It might require some time depending on the number of products, orders and customers you have.
- Upgrade is done. Head to frontend and backend and see if everything looks normal.
Need help with a Magento site? Hire us!
We have a great team of Magento experts who work hard and catch up the new trend of technology. If you want to upgrade/migrate your existing Magento websites to the latest Magento 2 environment or build new eCommerce websites on Magento 2, please contact us here.