How to install Magento 2.4 On XAMPP

Recently Magento has released Magento 2.4 version with many improvements and useful features, especially Magento switched to the Elasticsearch search method, which made people eager to install it on localhost. The tricky thing happens when the install button is lost in the installer. It is a conundrum for users who want to experience Magento 2.4 on localhost. But after a period of research, we can install it successfully, follow the posts How to install Magento 2.4 On XAMPP to be able to do it.

1. Check Magento 2.4 System Requirement

First, you should check the system requirements of Magento 2.4 to choose compatible XAMPP and Elasticsearch versions.

M24 System Requirement

You need to pay attention to the version requirements of Apache, MySQL, PHP, and Elasticsearch. Here, Magento 2.4 requires:

  • Apache Version 2.4
  • MySQL Version 8.0
  • PHP Version 7.3, 7.4
  • Elasticsearch Version 7.6.x

Also, you should pay attention to a few required PHP extensions.

2. Download and Install XAMPP

Based on the requirements above, we proceed to select an appropriate XAMPP version. You can download XAMPP here.

Choose XAMPP Version

We see that XAMPP version 7.4.12 conforms to the requirements set forth above, we proceed to download and install it.

Install XAMPP

3. Download Magento 2.4.1

Next, We download the version Magento 2.4.1 include sample data.

Download Magento 2.4.1 sample data

Unzip it to the XAMPP’s htdocs directory.

Unzip Magento 2.4.1

4. Download and Install Composer

After downloading Magento CE 2.4 sample data, we download and install Composer. You can access here to download Composer.

Download Composer

At the time of installation, choose the correct path to the php.exe of XAMPP just installed.

Composer choose path of XAMPP

You can check if the Composer installation was successful or not by opening the Command Prompt with administrator privileges. Next, check with composer command.

Check Composer

5. Download and Install Elasticsearch

As of Magento 2.4.0, MySQL is no longer used for searching. You must use Elasticsearch, it is a very important part of getting Magento 2.4 installed.

We downloaded Elasticsearch 7.6.2 into XAMPP’s htdocs directory and unzip it, you can use the latest version here.

Download and unzip Elasticsearch

Run elasticsearch.bat as an administrator in the htdocs/elasticsearch-7.6.2/bin directory.

Run elasticsearch.bat as administrator
Run cmd elasticsearch

You can check it at localhost with port 9200: localhost:9200

Check Elasticsearch

6. Configure extensions before installing

You open XAMPP Control Panel. Next, open php.ini in Apache’s config.

Open Apache's Config

Find lines

;extension=intl
;extension=soap
;extension=sockets
;extension=xsl

replace to

extension=intl
extension=soap
extension=sockets
extension=xsl

by removing the “;” in front of.

Edit php.ini

Restart Apache and MySQL in XAMPP Control Panel.

Restart XAMPP

7. Fix Magento_Theme Error

To fix Module ‘Magento_Theme’ Error, go to xampp/htdocs/magento241/vendor/magento/framework/Image/Adapter/Gd2.php line 86 replace the following function with the below code:

private function validateURLScheme(string $filename) : bool
{
    if(!file_exists($filename)) { // if file not exist
        $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
        $url = parse_url($filename);
        if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) {
            return false;
        }
    }
    return true;
}

8. Create a new database

Create a new database by access localhost/phpmyadmin/. Next, select New, give the database a name and click Create.

Create a new database

9. Install Magento 2.4.1

Go to the folder containing the Magento 2.4.1 created earlier, in the address bar type cmd or the path of the Command Prompt.

Open cmd in Magento folder

Then the Command Prompt window will appear, we enter the command:

php bin/magento setup:install --base-url="http://localhost/magento241/" --db-host="localhost" --db-name="magento241" --db-user="root" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --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

Note: edit base-url, db-name, admin account.

install magento command

After the installation, will display like this:

install magento successfully

Then, You run the commands:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

The path to access your storefront is localhost/magento241.

The path to enter the Admin Panel, you just need to add /admin in the back: localhost/magento241/admin.

If you see that your Admin Page does not display information, only gray, then you refer to How To Fix Blank Admin Page On Magento 2.3 In Windows to fix that.

If you have problems with the Admin Page: “Failed to send the message. Please contact the administrator”.

Two-Factor Authorization Error

You need to disable the Two-Factor Authorization module using the following command:

php bin/magento module:disable Magento_TwoFactorAuth

So we have successfully installed Magento 2.4.1 on localhost. Here are the results:

localhost_magento241_storefront
localhost_magento241_admin

This is How to install Magento 2.4 On XAMPP.

Follow us for more helpful article!

We hope this is useful blog for you.

Thank you for reading!

4.8 6 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Magento
Magento
January 25, 2021 9:00 am

Hi Aaron, magento 2.4 works with composer 2 ? I don’t think so, but I see composer v2.0.7 in one of the images.

1
0
Would love your thoughts, please comment.x
()
x