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.

Install by cloning repositories

Install sample data by cloning repositories

This topic discusses how to clone and add Magento sample data if you cloned the Magento GitHub repository. This method is intended only for contributing developers (that is, developers who plan to contribute to the Magento 2 codebase).

If you’re not a contributing developer, choose one of the other options displayed in the table of contents on the left side of the page.

Contributing developers can use this method of installing sample data only if all of the following are true:

You can use sample data with either the develop branch (more current) or a released branch (such as 2.2 or 2.2.5 (more stable)). We recommend you use a released branch because it’s more stable. If you’re contributing code to the Magento 2 repository and you need the most recent code, use the develop branch. Regardless of the branch you choose, you must clone the corresponding branch of the Magento 2 GitHub repository. For example, sample data for the develop branch can be used only with the Magento 2 develop branch.

See the following sections:

Clone the sample data repository

This section discusses how to install Magento sample data by cloning the sample data repository. You can clone the sample data repository in any of the following ways:

Clone with SSH

To clone the Magento sample data GitHub repository using the SSH protocol:

  1. In a web browser, go to the Magento sample data repository.
  2. Next to the name of the branch, click SSH from the list.
  3. Click Copy to clipboard

    The following figure shows an example.

    Clone the Magento GitHub repository using SSH

  4. Change to your web server’s docroot directory.

    Typically, for Ubuntu, it’s /var/www and for CentOS it’s /var/www/html.

    Need help locating the docroot?

  5. Enter git clone and paste the value you obtained from step 1.

    An example follows:

    1
    
     git clone git@github.com:magento/magento2-sample-data.git
    
  6. Wait for the repository to clone on your server.

    If the following error displays, make sure you shared your SSH key with GitHub:

    1
    2
    3
    
     Cloning into 'magento2'...
     Permission denied (publickey).
     fatal: The remote end hung up unexpectedly
    
  7. Ensure you checkout the branch of the sample data repository that corresponds with the branch you used from the main magento2 repository.

    For example:

    If you used the 2.2-develop branch of the Magento 2 repository, the Sample Data branch should be 2.2-develop.

    If you used the 2.2.5 branch of the Magento 2 repository, the Sample Data branch should be 2.2.5.

    To checkout the correct branch, run the following command from the sample data repository’s root directory (assuming you need the 2.2.5 branch):

    1
    
     git checkout 2.2.5
    
  8. Change to <magento_root>.
  9. Enter the following command to create symbolic links between the files you just cloned so sample data works properly:

    1
    
     php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="<path_to_your_magento_instance>"
    
  10. Wait for the command to complete.

  11. See Set file system permissions and ownership.

Clone with HTTPS

To clone the Magento sample data GitHub repository using the HTTPS protocol:

  1. In a web browser, go to the Magento sample data repository.
  2. On the right side of the page, under the clone URL field, click HTTPS.
  3. Click Copy to clipboard.

    The following figure shows an example.

    Clone the Magento GitHub repository using HTTPS

  4. Change to your web server’s docroot directory.

    Typically, for Ubuntu, it’s /var/www and for CentOS it’s /var/www/html.

  5. Enter git clone and paste the value you obtained from step 1.

    An example follows:

    1
    
     git clone https://github.com/magento/magento2-sample-data.git
    
  6. Wait for the repository to clone on your server.
  7. Ensure you checkout the branch of the sample data repository that corresponds with the branch you used from the main magento2 repository.

    For example:

    If you used the 2.2-develop branch of the Magento 2 repository, the Sample Data branch should be 2.2-develop.

    If you used the 2.2.5 branch of the Magento 2 repository, the Sample Data branch should be 2.2.5.

    To checkout the correct branch, run the following command from the sample data repository’s root directory (assuming you need the 2.2.5 branch):

    1
    
     git checkout 2.2.5
    
  8. Change to <magento_root>.
  9. Enter the following command to create symbolic links between the files you just cloned so sample data works properly:

    1
    
     php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="<path_to_your_magento_instance>"
    

    For example,

    1
    
     php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="/var/www/magento2"
    
  10. Wait for the command to complete.
  11. See the next section.

If you’re installing sample data after installing Magento, you must also run the following command to update the database and schema:

1
<magento_root>/bin/magento setup:upgrade

Set file system ownership and permissions

Because the php build-sample-data.php script creates symlinks between the sample data repository and your Magento 2 repository, you must set file system permissions and ownership in the sample data repository. Failure to do so results in errors accessing the storefront.

To set file system permissions and ownership on the sample data repository:

  1. Change to your sample data clone directory.
  2. Set ownership:

    1
    
     chown -R :<your web server group name> .
    

    Typical examples:

    CentOS: chown -R :apache .

    Ubuntu: chown -R :www-data .

  3. Set permissions:

    1
    
     find . -type d -exec chmod g+ws {} +
    
  4. Clear static files:

    1
    
     cd <your Magento Open Source install dir>/var
    
    1
    
     rm -rf cache/* page_cache/* generation/*
    
Updated