Magento 2.4.2 installation with Sample Data on localhost Xampp Using Command line, Elastic search composer with step by step in a simple way. During the installation process many errors you will get. But in this article, you will be going to install the Magento 2.4.2 using the command line with a complete fix and error-free.
To install Magento 2.4.2 follow the below steps with complete detail and every error solution explained in a simple way.
Steps for Magento 2.4.2 installation with Sample Data on localhost Xampp Using Command line.
For Installing the Magento, Magento 2.4.2 depends on the composer, Elasticsearch. So it is very much important before installing Magento, we need to install Elasticsearch and composer. One of the important things in Magento is Elasticsearch, which is compulsory.
In this installation process, you going to discussion regarding both the latest version Magento 2.4.2 and Magento 2.4.2-p1
Magento 2.4.2 Requirements
For Installing Magento 2.4.2 there is a certain requirement for running and execution on localhost should fulfill. The below Image is helpful for getting information regarding the 2.4.2 requirement.
For Magento 2.4.2 following points are important for a successful installation.
- PHP 7.4
- Apache 2.4
- nginx 1.8
- Varnish 6.4
- Redis 6.0
- MySQL 8.0
- Elasticsearch 7.9
- Composer 2.x
For full detail and information regarding you can check to visit Magento Requirement
How to Install Xampp in Windows 7,8,10 (2021)
Installation of Xampp on the window is very simple. It requires running the PHPMyAdmin, PHP, and many more. To Install the Xampp check with the below download link. Using this link can download them easily.
If you get any error on this, you can directly enter Xampp download in the google search engine to download. You will get the download official site from where you can download it. On that official site, you can download Xampp for different Operating systems such as Mac, Windows, and Linux as you see in the above image.
How to Install Composer in Windows 7,8,10
Just check the below link to download and install composer on window 7, 8, 10.
Download Composer for window version
It is very important for managing the various library management tool for the packages of PHP. After downloading the composer just click on the Exe file for the installation process to start. After the installation is complete check the composer successfully working or not by entering the command in the cmd line.
You will get a screen like below.
Check the current version of the composer is 2.1.5 which is compatible with Magento 2.4.2 installation. To you clarify you can check the above image regarding the version. In the requirement, it is mentioned as 2.x. Which means it is compatible.
Install Elasticsearch on Windows for Magento 2.4
Application Elasticsearch is important for the Magento 2.4 installation. The system verifies the Elasticsearch installation and configuration. It is done during the installation process. If something gets wrong during verification, the process of installation will stop.
For downloading Elasticsearch visit the link: Download Elasticsearch.
After download, unzip the folder and go inside the folder path:
In the bin folder, you will get elasticsearch.bat, just right-click on it and run as an administrator.
Keep the window running background
For confirmation regarding the Elasticsearch is running or not, open the browser and run localhost:9200
If you get the result like in the below image then Elasticsearch work properly
How to Install Magento 2.4 using command line on localhost Xampp
Before starting with the installation process of Magento 2.4.2, we need to configure the file
php.in. If the configuration is done properly then the process becomes easier for installation.
php.ini configuration for Magento 2
The extension is needed for the Magento 2.4.2 installation, we need to check if it is enabled or not. If it is not enabled then we have to enable and after enabling save the file and Do forget to restart Apache and MySQL in Xampp.
Below is the extension we have to check.
You can enable it by open the file which is present inside the folder path:
or you can do it by directly open the file using Xampp and make the changes, save it and again restart the apache and MySQL.
Below are some of the PHP extension which we have enabled it by removing the “;”. It is given before the extension name. After removing this save the file and restart the Xampp. What you make the changes it is given in below code
;extension=intl ;extension=soap ;extension=xsl ;extention=sockets ;extension=sodium as set max_execution_time=18000 max_input_time=1800 memory_limit=4G
After making all these changes and restart the Apache by clicking the stop and then the start button on Xampp.
Our next step is to create a database using PHPMyAdmin using Xampp. Inside the Xampp you have to click on the button admin to open the PHPMyAdmin.
Now step to create a database in PHPMyAdmin for installation of Magento
If you want to change the password you can do it by command using the shell in Xampp you can open the shell and enter the below command to changes the password. Password is not set to default in MySQL on Xampp.
Use the below command to set the password using the shell.
mysqladmin.exe -u root password yourpassword
You can be made changes to the file to set the password. And file path
Install Magento 2.4.2 using composer on localhost Xampp with sample data (command line)
Before starting with the installation, we going to change the domain from localhost to a professional domain such as www.yourdomain-name.com. For this, you have to make changes to some of the following files present in the given below path.
The first filename
httpd-vhosts.conf and path
and another file is the host file and the path is given below.
After doing all these changes restart apache and MySQL on Xampp
Install Magento 2.4.2 or Magento 2.4.2-p1 using the command line
Use the below command to download and install Magento in a different version.
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=<magento-version> <directory-name-to-install> // For Magento Version 2.4.2 command (example) composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.2 magento242/ // For Magento Version 2.4.2-p1 command (example) composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.2-p1 magento242/
Now to install use the below command. It is very important toduring the installation process as mention above regarding Elastricsearch.
Commands:- php bin/magento setup:install --base-url="http://www.magento242.com" --db-host="localhost" --db-name="magento24" --db-user="root" --db-password="" --admin-firstname="admin" --admin-lastname="admin" --admin-email="firstname.lastname@example.org" --admin-user="admin" --admin-password="admin123" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --search-engine=elasticsearch7 --elasticsearch-host="localhost" --elasticsearch-port=9200 Replace these values: –base-url: your magento 2 installation folder –db-name: your database name –db-password: your database password
During the installation, you will get an error regarding the Image Adapter for trying to open image files
Gd2.php Line No. 72
It is due to a function called validateURLScheme function. It always returns false due to checking of URL format, because the local file format is not valid. To fix this issue you have done small changes for working properly in the file called Gd2.php
You have to just replace the code place in the file present at the path at the line near 92.
To Fix an Error Regarding Gd2 Image Adapter clicks to visit Solution For Gd2 in detail.
Magento 2 4 install sample data Using Command-Line
The next step is to install a sample data, to install sample data using the below command.
php bin/magneto sampledata:deploy
Now enable all the modules, to enable it to use the below command. after enable check the Elasticsearch is working background or not. To check it browse with link localhost:9200 as shown above in the image.
php bin/magento module:enable --all
Now the final step is used to install Magento using the given below set upgrade command.
php bin/magento setup:upgrade
Finally done with the complete installation of Magento.
After this use the below command to complete the process.
php bin/magento setup:static-content:deploy -f php bin/magento cache:flush
Error Solution for Magento 2 blank screen after installation
Many users get Magento 2 blank screen after installation and frontend lank page issue, To fix this issue you have to make the small change in the given file below and file path
Make the change in the file Validator
$realPath = $this->fileDriver->getRealPath($path);
Replace with the below-given code.
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
For detail about this error, you check with the Blank Screen Solution.
After Successful installation of Magento 2.4.2 front and admin, you will get the result given below. Just refresh the browser by using link base URL of your Magento installation
Admin End after the installation of Magento 2
During Login of Magento getting Error like given below in the image.
The Error is “Failed to send message please contact administrator”
To Fix the Error you have to disable the module called “Two-Factor Authorization” on the localhost
Use the below command to disable the module
php bin/magento module:disable Magento_TwoFactorAuth
After disabling the module use flush command cache and again login to the admin.
Then you will see successfully done login to the admin. Finally done all processes of a Magento installation.
Download Complete Guide Magento 2.4.2 Installtion