Piyush Dankhra

About me
moon indicating dark mode
sun indicating light mode

Last updated: May 31, 2024

Install Fresh Magento 2 Using Reward Within 5 Minutes

Setting up and configuring a local server for Magento 2 can be a daunting task for developers. However, with the Reward tool, this process is simplified, making it easy to set up Magento 2 development environments on your local computer. During my technical session titled “Rewardenv - A better CLI tool to create dev environment” at Meet Magento India 2023, I highlighted how Reward can streamline this setup process for developers.

What is Reward?

Reward is an environment management tool designed to streamline the setup and configuration of various development environments, including Magento 2. It significantly reduces the time and effort required to get a Magento 2 environment up and running.

Steps to Install Magento 2.4.7 with Sample Data

Let’s walk through the steps to install Magento 2.4.7 with sample data using Reward.

  1. Prerequisite
  2. Create a Directory for Your Magento 2 Project
  3. Initialize the Reward .env File
  4. Edit and Configure the .env File
  5. Set Up the Magento Composer Keys
  6. Install and Bootstrap the Magento 2 Environment
  7. Check the Installation Output

Step 1: Prerequisite

Ensure that Reward is already installed on your local computer.

Step 2: Create a Directory for Your Magento 2 Project

mkdir /var/www/html/m247
cd /var/www/html/m247

Step 3: Initialize the Reward .env File

This step creates the .env file that we can use to configure the environment, including settings like PHP, Varnish, and Composer versions.

reward env-init m247

Step 4: Edit and Configure the .env File

Let’s edit the .env file and disable Varnish, Redis, and RabbitMQ by updating the following environment variables for a local development environment. You can keep them enabled if you prefer.

Update the following environment variables:

REWARD_ENV_NAME=m247
REWARD_ENV_TYPE=magento2
REWARD_WEB_ROOT=/
TRAEFIK_DOMAIN=m247.test
TRAEFIK_SUBDOMAIN=
TRAEFIK_EXTRA_HOSTS=
REWARD_DB=true
REWARD_ELASTICSEARCH=false
REWARD_OPENSEARCH=true
REWARD_OPENSEARCH_DASHBOARDS=false
REWARD_VARNISH=false // change to false
REWARD_RABBITMQ=false // change to false
REWARD_REDIS=false // change to false
REWARD_MERCURE=false
ELASTICSEARCH_VERSION=7.16
OPENSEARCH_VERSION=1.2
MARIADB_VERSION=10.4
NODE_VERSION=16
PHP_VERSION=8.2
RABBITMQ_VERSION=3.9
REDIS_VERSION=6.0
VARNISH_VERSION=7.0
COMPOSER_VERSION=2.2.22
REWARD_SYNC_IGNORE=
REWARD_ALLURE=false
REWARD_SELENIUM=false
REWARD_SELENIUM_DEBUG=false
REWARD_BLACKFIRE=false
REWARD_SPLIT_SALES=false
REWARD_SPLIT_CHECKOUT=false
REWARD_TEST_DB=false
REWARD_MAGEPACK=false
BLACKFIRE_CLIENT_ID=
BLACKFIRE_CLIENT_TOKEN=
BLACKFIRE_SERVER_ID=
BLACKFIRE_SERVER_TOKEN=
XDEBUG_VERSION=

Step 5: Set Up the Magento Composer Keys

reward env up -- php-fpm
reward shell
composer config -a -g http-basic.repo.magento.com yourpublickey yourprivatekey
exit

Step 6: Install and Bootstrap the Magento 2 Environment

reward bootstrap --disable-tfa --full --magento-version=2.4.7
Explanation of the Parameters:
  • --disable-tfa: Disables Magento two-factor authentication, which is enabled by default and typically disabled using the bin/magento module:disable command.
  • --full: Installs Magento with sample data. You can skip this if you don’t want to include sample data, but it can be installed later if needed.
  • --magento-version: Specifies the Magento version to install.

Step 7: Check the Installation Output

Once the reward bootstrap command completes successfully, you will see output similar to the following:

...
...
full_page
config_webservice
translate
INFO ...cache flushed.
INFO ...Magento installed successfully.
INFO Base Url: https://m247.test
INFO Backend Url: https://m247.test/admin
INFO Admin user: localadmin
INFO Admin password: 0UvA2GisxYjIkXKn
INFO ...bootstrap process finished.

The Base URL is the Magento frontend link, and the Backend URL is the Magento admin URL. It creates the default admin user with username localadmin with a randomly generated password for admin login.

Conclusion

As demonstrated, installing a fresh Magento 2 environment with Reward is straightforward and can be completed within a few minutes. This tool greatly simplifies the process, making it much more efficient for developers.

For more details, refer to the Reward documentation.


About me.
Adobe Certified Expert - Adobe Commerce Developer / Front-End Developer / Business Practitioner
Adobe Subject Matter Expert - Adobe Commerce Front End Developer / Business Practitioner
Working on Magento 2 / Hyvä