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.
- Prerequisite
- Create a Directory for Your Magento 2 Project
- Initialize the Reward .env File
- Edit and Configure the .env File
- Set Up the Magento Composer Keys
- Install and Bootstrap the Magento 2 Environment
- 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/m247cd /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=m247REWARD_ENV_TYPE=magento2REWARD_WEB_ROOT=/TRAEFIK_DOMAIN=m247.testTRAEFIK_SUBDOMAIN=TRAEFIK_EXTRA_HOSTS=REWARD_DB=trueREWARD_ELASTICSEARCH=falseREWARD_OPENSEARCH=trueREWARD_OPENSEARCH_DASHBOARDS=falseREWARD_VARNISH=false // change to falseREWARD_RABBITMQ=false // change to falseREWARD_REDIS=false // change to falseREWARD_MERCURE=falseELASTICSEARCH_VERSION=7.16OPENSEARCH_VERSION=1.2MARIADB_VERSION=10.4NODE_VERSION=16PHP_VERSION=8.2RABBITMQ_VERSION=3.9REDIS_VERSION=6.0VARNISH_VERSION=7.0COMPOSER_VERSION=2.2.22REWARD_SYNC_IGNORE=REWARD_ALLURE=falseREWARD_SELENIUM=falseREWARD_SELENIUM_DEBUG=falseREWARD_BLACKFIRE=falseREWARD_SPLIT_SALES=falseREWARD_SPLIT_CHECKOUT=falseREWARD_TEST_DB=falseREWARD_MAGEPACK=falseBLACKFIRE_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-fpmreward shellcomposer config -a -g http-basic.repo.magento.com yourpublickey yourprivatekeyexit
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 thebin/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_pageconfig_webservicetranslateINFO ...cache flushed.INFO ...Magento installed successfully.INFO Base Url: https://m247.testINFO Backend Url: https://m247.test/adminINFO Admin user: localadminINFO Admin password: 0UvA2GisxYjIkXKnINFO ...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.