Command-line upgrade with sample data

Command-line upgrade to Magento 2.3 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.3 (including a Release Candidate) from any earlier version using the command line

To upgrade to Magento 2.3 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
    
  4. Upgrade the Magento software version using commands of the following format:

    1
    
    composer require <product> <version> --no-update
    
    1
    
    composer require <sample data module-1>:<version> ... <sample data module-n>:<version> --no-update
    
    • Example for Magento Open Source:

      1
      
      composer require magento/product-community-edition 2.3.0 --no-update
      
      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
      
    • Example for Magento Commerce:

      1
      
      composer require magento/product-enterprise-edition 2.3.0 --no-update
      
      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
      

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

  1. Update dependencies:

    1
    
    composer update
    
  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/*
    
  4. Upgrade Magento:

    1
    
    php bin/magento setup:upgrade
    

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>
1
chmod -R g+w var vendor pub/static pub/media app/etc
1
chmod u+x bin/magento

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

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/*

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

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