The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

How to install Magento 2 with Sample Data

Magento is an ecommerce platform built on open source technology that provides online merchants with a flexible shopping cart system, as well as control over the look, content and functionality of their online store. Magento offers powerful marketing, search engine optimization, and catalog-management tools (Wikipedia).

Sample Data include sample products, sample orders, and other related data, based on the Luma theme, to serve as test data. While preparing to launch your store or testing new features and updates, online stores can use this data. Therefore, today let’s take a look at how to install Magento 2 with Sample data.

Note: Previously, we showed you how to install Magento 2.3.5 with Sample data. However, this version is now out of date, so the instructions below are only for reference. To catch up with the Magento 2.4.6 ver, please visit: Install Magento 2 on Ubuntu/Debian via Composer & Downloading Code.

How to install Magento 2 with Sample Data by Command Line and Interface (CLI)

This installation guide will show you how to install Magento 2 latest version on your own server or hosting for Magento 2

Step 1: Getting started: select solution

There are some solutions we can get started with.

  • Install from Zip file: Easy installation, no command line.
  • Metapackage: Use Composer to install Magento
  • Install from Git repository: Contributing developer

In this guide, we will show how to install as the #1 solution. It is easy to get started.

  • Prerequisites: Before you continue, make sure you’ve finished all of the following:

Step 2: Install Magento 2 Step by Step

  • Download Magento packages
  • Upload to your server
  • Update permission
  • Running the Magento Setup Wizard
  • Finish installation process

2.1. Download Magento packages

2.2. Upload to your server

Let’s download a zip file and now time to upload it to the server. You can use WinSCP, Filezilla to upload it to the server, then extract it to public_html directory (let’s call it: Magento root directory).

  • If you are using shared hosting, you can use unzip/extract feature to extract the Magento package.
  • If you are running on your server, let follow the commands:
File format and command
# File .tar.gz	
tar zxf <filename>

# File .zip
unzip <filename>

Update permission

Add write permission for the following folders: var, app/etc, pub by running below command line:

chmod 777 -R var
chmod 777 -R app/etc
chmod 777 -R pub

You may get this error if it does not have permission.

2.3. Running the Magento Setup Wizard

The Setup Wizard is a multi-page wizard that enables you to go back and forward one page at a time. You cannot skip pages, and you must enter all required information on every single page before you can proceed to the next page.

  • Enter the following URL in your browser address bar: http://www.example.com/magento2. example.com is your domain name such as: localhost, localhost.com, 127.0.0.1 or your staging domain. magento2 is Magento 2 folder in htdocs Usually, it is http://localhost/magento2.
  • On the initial page, click Agree and Set Up Magento. Continue with the following topics in the order presented to complete the installation.

Running the Magento Setup Wizard

2.3.1. Readiness Check

Readiness Check

  • Click Start Readiness Check. If any errors are displayed, you must resolve them before you continue. Click More detail if available to see more information about each check. Readiness Check error
  • Click Next
2.3.2 Add a Database

Fill database information then click Next

2.3.3 Web Configuration
  • Enter the following information:
    • Your Store Address: http://www.example.com
    • Magento Admin Address: Enter the relative URL by which to access the Magento Admin. e.g: secret, backend
  • Then click Next
2.3.4. Customize Your Store

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
  • From the Store Default Time Zone list, click the name of your store’s time zone.
  • From the Store Default Currency list, click the default currency to use in your store.
  • From the Store Default Language list, click the default language to use in your store.
  • Expand Advanced Modules Configuration to optionally enable or disable modules before you install the Magento software.

How to install Magento 2 Magento modules configuration

Click Next

Important!: Use Skip dependency check for individual modules with caution. We recommend against it because a typical reason for this error is you manually edited the deployment configuration. Editing the deployment configuration is not recommended because future Magento software updates can undo your changes.

2.3.5. Create Admin Account

Now enter admin information such as

  • New Username
  • New E-Mail
  • New Password
  • Confirm Password
  • Then click Next
2.3.6. Install

mageplaza

After completing all previous steps in the Setup Wizard, click Install Now.

Installation Success: The message Success will be displayed to indicate a successful installation.

Step 3: Check the result

Now go to the frontend and backend to see the result

Frontend

How to install Magento 2 Frontend

Backend

How to install Magento 2 Frontend

How to install Magento 2 by cloning repositories

To install Magento 2 by cloning the sample data repositories, you can select these two ways: Clone with the SSH protocol or with the HTTPS protocol.

Clone with the SSH protocol

  • In the web browser, please access the website Magento 2 Sample Data.
  • Click “SHH” on the lish next to the branch name.
  • Click “Copy to clipboard”
  • Change to docroot directory of your web server.

/var/www/html for CentOS /var/www for Ubuntu

  • Enter git clone and paste the value from the previous step into this field

For example: git clone [email protected]:magento/magento2-sample-data.git

  • Wait for your server to clone the repository.
  • Make sure that the branch of the sample data repository you checkout matches the branch you used from the magento 2 main repository.
  • Turn to
  • Write this command to make symbolic links between the files you have cloned so that the sample data functions properly:

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

After that, please wait to the command completing.

Clone with the HTTPS protocol

  • In the web browser, please access the website Magento sample data repository.
  • Click on “HTTPS” under the cone URL file on the page’s right.
  • Click “Copy to clipboard”
  • Change to docroot directory of your web server. /var/www/html for CentOS /var/www for Ubuntu
  • Enter ‘git clone’ and paste the value from the previous step into this field For example: git clone https://github.com/magento/magento2-sample-data.git
  • Wait for your server to clone the repository.
  • Make sure that the branch of the sample data repository you checkout matches the branch you used from the magento 2 main repository.
  • Turn to <magento_root>
  • Write this command to make symbolic links between the files you have cloned so that the sample data functions 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" After that, please wait to the command completing.

That is everything you need to do to install Magento 2 with Sample data by cloning repositories.

How to install Magento 2 by composer.json file

There are some steps you can follow to install Magento 2 Sample data by composer.json:

  • Enter this code to your web’s root composer.json file. Each version will have a different code: For Magento 2.4.x:
    {
    "require": {
        "magento/module-bundle-sample-data": "100.4.*",
        "magento/module-catalog-rule-sample-data": "100.4.*",
        "magento/module-catalog-sample-data": "100.4.*",
        "magento/module-cms-sample-data": "100.4.*",
        "magento/module-configurable-sample-data": "100.4.*",
        "magento/module-customer-sample-data": "100.4.*",
        "magento/module-downloadable-sample-data": "100.4.*",
        "magento/module-grouped-product-sample-data": "100.4.*",
        "magento/module-msrp-sample-data": "100.4.*",
        "magento/module-offline-shipping-sample-data": "100.4.*",
        "magento/module-product-links-sample-data": "100.4.*",
        "magento/module-review-sample-data": "100.4.*",
        "magento/module-sales-rule-sample-data": "100.4.*",
        "magento/module-sales-sample-data": "100.4.*",
        "magento/module-swatches-sample-data": "100.4.*",
        "magento/module-tax-sample-data": "100.4.*",
        "magento/module-theme-sample-data": "100.4.*",
        "magento/module-widget-sample-data": "100.4.*",
        "magento/module-wishlist-sample-data": "100.4.*",
        "magento/sample-data-media": "100.4.*"
    }
    }
    
  • For Magento 2.3.x: Change 100.4 to 100.3 in the above code.
  • For Magento 2.2.x: Change 100.3 to 100.2 in the above code.

  • After that, please pass this command: composer update

  • Follow this guide if you are asked for a username and password.
    • Username is the public key
    • Password is the private key

That is everything you need to do to install Magento 2 with Sample data by composer.json file.

Common Errors when Installing Magento 2 with Sample Data and Ways to Fix Them

In this part, Mageplaza would like to give you three errors that usually happen during installing Magento 2 with Sample Date process and ways to fix them.

Magento Mode Error

  • Error Description: This error occurs when Magento is not set to the correct mode during the installation process.

  • Solution:

    • To resolve this error, ensure that you set the correct mode before installing Magento. Open a command-line interface, navigate to the Magento root directory, and run the following command: ` php bin/magento deploy:mode:set developer `

    • Replace “develop” with “production” if you want to set the production mode. After setting the mode, proceed with the installation process.

PHP max_execution_time Error

  • Error Description: This error occurs when the PHP max_execution_time value is set too low, causing the installation process to timeout.

  • Solution:

    • To resolve this problem, increase the max_execution_time value in your PHP configuration. Locate the php.ini file and modify the following line: ` max_execution_time = 300 `

    • Increase the value to a higher value, such as 600 or 900, to give the installation process enough time to complete. Save the changes and restart your web server for the new configuration to take effect.

File System Permissions Error

  • Error Description: This error occurs when the Magento installation script does not have the necessary file system permissions to write or modify files and directories.

  • Solution

    • To resolve, you should ensure that the correct file system permission are set for your Magento installation. Typically, directories should have permissions of 755 and files should have permissions of 644. You can set the permission using the following command from the Magento root directory. ` find . -type d -exec chmod 755 {} \; ` ` find . -type f -exec chmod 644 {} \; `

    • Additonally, make sure that the web server user has appropriate ownership of the Magento files and directories. You can set the ownership using the following command: ` chown -R web-server-user:web-server-group . `

    • Replace web-server-user and web-server-group with the actual user and group of your web server.

Conclusion

Installing your Magento 2 store using Sample data could be a great approach, as it allows you to test beforehand how the store looks and operates. It also helps to check the changes after installing new extensions or running an update. This guide has shown you how to install sample data for your Magento 2 store, and if you want to discover other Magento 2-related topics, check the below recommendations from us. And don’t forget to leave comments as you go!

Related Post

Image Description
Hello, I'm the Chief Technology Officer of Mageplaza, and I am thrilled to share my story with you. My deep love and passion for technology have fueled my journey as a professional coder and an ultra-marathon runner. Over the past decade, I have accumulated extensive experience and honed my expertise in PHP development.

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
x

    Explore Our Products:

    People also searched for

    Subscribe

    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    comment
    iphone
    go up