Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Command-line upgrade with sample data

Command-line upgrade to Magento 2.1 with sample data

These instructions apply to Magento Open Source and Magento Commerce users only if all of the following are true:

  • You have installed optional sample data
  • You are 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:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Change to the Magento installation directory.
  3. Back up your current composer.json file:
    1
    
    cp composer.json composer.json.bak
    
    Copy
  4. Upgrade the Magento software version using commands of the following format:
    1
    
    composer require <product> <version> --no-update
    
    Copy
    1
    
    composer require <sample data module-1>:<version> ... <sample data module-n>:<version> --no-update
    
    Copy
    • Example for Magento Open Source:
      1
      
       composer require magento/product-community-edition 2.1.0 --no-update
      
      Copy
      1
      
       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 
      
      Copy
    • Example for Magento Commerce:
      1
      
      composer require magento/product-enterprise-edition 2.1.0 --no-update
      
      Copy
      1
      
      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 magento/module-gift-card-sample-data:100.1.0 magento/module-customer-balance-sample-data:100.1.0 magento/module-target-rule-sample-data:100.1.0 magento/module-gift-registry-sample-data:100.1.0 magento/module-multiple-wishlist-sample-data:100.1.0 --no-update
      
      Copy

To upgrade to a Release Candidate, append -rc<x> to the version of each module. For example, -rc3.

  1. Update dependencies:
    1
    
    composer update
    
    Copy
  2. If prompted, enter your authentication keys.
  3. Wait for dependencies to update.

Finish your upgrade

After you have reset file system permissions:

  1. If you haven’t done so already, log in to your Magento server as, or switch to, the Magento file system owner.
  2. Change to your Magento installation directory.
  3. Manually clear the var/cache, var/page_cache, and var/generation directories. A sample command follows:
    1
    
    rm -rf var/cache/* var/page_cache/* var/generation/*
    
    Copy
  4. Upgrade Magento:
    1
    
    php bin/magento setup:upgrade
    
    Copy

Apply file system permissions and ownership

As part of the sample data upgrade process, you must apply current file system permission and ownership as discussed in the following sections. Failure to do so will cause your upgrade to fail.

For more information about file system ownership and permissions, see Overview of ownership and permissions.

One-user ownership and permissions

If you run the Magento application as one user (which is typical of shared hosting environments), change file system permissions and ownership as follows:

1
cd <magento_root>
Copy
1
chmod -R g+w var vendor pub/static pub/media app/etc
Copy
1
chmod u+x bin/magento
Copy

To optionally enter all commands on one line, enter the following assuming Magento is installed in /var/www/html/magento2:

1
cd /var/www/html/magento2 && chmod -R g+w var vendor pub/static pub/media app/etc && chmod u+x bin/magento
Copy

After you set file system permissions, manually clear the var/cache, var/page_cache, and var/generation directories.

A sample command follows:

1
rm -rf var/cache/* var/page_cache/* var/generation/*
Copy

Two-user ownership and permissions

If you run the Magento application with two users, enter the following commands as a user with root privileges:

1
cd <magento_root>
Copy
1
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
Copy
1
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
Copy
1
chown -R :<web server group> .
Copy
1
chmod u+x bin/magento
Copy

To optionally enter all commands on one line, enter the following assuming Magento is installed in /var/www/html/magento2 and the web server group name is apache:

1
cd /var/www/html/magento2 && find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R :apache . && chmod u+x bin/magento
Copy