Our Feature Items: SM Market // SM AutoStore // SP Revo
Shopping cart (0)

How To Upgrade Magento 2 to The Latest Version - Command-line Upgrade

Rate this item
(1 Vote)
Written by  Katy
Tuesday, 22 August 2017 11:29
How To Upgrade Magento 2 to The Latest Version - Command-line Upgrade - 5.0 out of 5 based on 1 vote

Hi guys! We come back. Maybe in the previous post How To Upgrade Magento 2 to The Latest Version - Run System Upgrade, you have already know what should do when having upgraded file of Magento 2. However, as we mentioned before, there are 2 ways to take action. And today, we will bring you the remaining way: Command-line Upgrade!

Thanks to Magento.com Commuinity again for giving us these fantastic way!


You can upgrade Magento from the command line if you installed the software using any of the following:

  • Downloaded the metapackage using composer create-project
  • Installed the compressed archive
  • If you cloned the Magento 2 GitHub repository, you cannot use this method to upgrade; instead, see Update the Magento application.
  • If you configured Magento use use pub as its root directory, see the next section.
  • If you're upgrading to Magento 2.1 (including a Release Candidate) from Magento 2.0.7 or earlier and you installed sample data, see Command-line upgrade to Magento 2.1 with sample data instead of this topic.

Prerequisite: pub directory root

This section applies to you only if you set the Magento root directory to /pub. If you did not do this, skip this section and continue with the next section.

If you use pub as your Magento root directory:

  • For the upgrade, create another subdomain or docroot that uses the Magento installation directory as its root.
  • Run the System Upgrade utility using that subdomain.

  • Use the following procedure to upgrade Magento using the command line.

Put your store in maintenance mode

To prevent access to your store while it’s being upgraded, put your store in maintenance mode.

You can optionally create a custom maintenance mode page.

To enable maintenance mode:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Enter the following command:
  3. php /bin/magento maintenance:enable

    For additional options, see Enable or disable maintenance mode.

Upgrade using the command line

To upgrade using the command line:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Change to the directory in which you installed the Magento software.
  3. For example, cd /var/www/html/magento2

  4. Enter the following commands in the order shown:
  5. composer require --no-update

    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

    For example, to upgrade to Magento CE version 2.0.13, enter:

    composer require magento/product-community-edition 2.0.13 --no-update

    composer update

    To upgrade to Magento EE version 2.0.13, enter:

    composer require magento/product-enterprise-edition 2.0.13 --no-update

    composer update

    If an error displays about a missing .gitignore files, see the Technical Bulletin (1/28/16).

  6. If prompted, enter your authentication keys.
  7. Manually clear var subdirectories:
  8. rm -rf /var/cache/*

    rm -rf /var/page_cache/*

    rm -rf /var/generation/*

    If you use a cache storage other than filesystem (e.g., Redis, Memcached, etc.) you need to manually clear the cache there too.

  9. Update the database schema and data:
  10. php bin/magento setup:upgrade
  11. Put your storefront online (that is, cancel maintenance mode):
  12. php bin/magento maintenance:disable
  13. Restart Varnish if you use it for page caching.
  14. service varnish restart
  15. Access your storefront.
  16. The following error might display:

    We're sorry, an error has occurred while generating this email.

    If so, perform the following tasks:

    1. Reset file system ownership and permissions as a user with root privileges.
    2. Clear the following directories and try again:

    /var/cache

    /var/page_cache

    /var/generation

Source: Magento.com

Google+
Joomla TemplatesFree Joomla TemplatesVirtuemart TemplatesK2 TemplatesJoomShopping TemplatesHikaShop TemplatesSobiPro TemplatesOpenCart Themes
Quà Tết Cao Cấp Hộp quà tết Giỏ quà tết Túi quà tết