Clone with SSH

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

  1. In a web browser, go to the 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 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.

  5. Enter git clone and paste the value you obtained previously.

    An example follows:

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

    NOTE
    If the following error displays, make sure you shared your SSH key with GitHub:
    Cloning into 'magento2'...
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
    
  7. Ensure you check out 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.4-develop branch of the Magento Open Source GitHub repository, the Sample Data branch should be 2.4-develop.

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

    git checkout 2.4-develop
    
  8. Change to <app_root>.

  9. Enter the following command to create symbolic links between the files that you cloned so sample data works properly:

    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.

  12. Run the following command:

    bin/magento setup:upgrade
    

Clone with HTTPS

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

  1. In a web browser, go to the 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 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 previously.

    An example follows:

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

  7. Ensure you check out 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.4-develop branch of the Magento Open Source GitHub repository, the Sample Data branch should be 2.4-develop.

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

    git checkout 2.4-develop
    
  8. Change to <magento_root>.

  9. Enter the following command to create symbolic links between the files that you cloned so sample data works properly:

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

    For example,

    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.

WARNING
If you’re installing sample data after installing Adobe Commerce, you must also run the following command to update the database and schema:
<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 Open Source 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:

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

    Typical examples:

    • CentOS: chown -R :apache .

    • Ubuntu: chown -R :www-data .

  3. Set permissions:

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

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

Complete the sample data installation

After you download the sample data packages, log in to your application server as, or switch to, the file system owner and enter the following command in <app_root> directory:

bin/magento setup:upgrade
Previous pageDownload Composer packages
Next pageRemove or update modules