How To Install Magento 2.4.7 On XAMPP

Magento 2.4.7 came out with a lot of improvements and useful features, especially a few tweaks to improve security. This makes it difficult to install on localhost. But after a period of research, we can install it successfully, follow the posts How to install Magento 2.4.7 On XAMPP to be able to do it.

1. Check Magento 2.4.7 System Requirement

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

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

  • PHP Version 8.2, 8.3
  • Elasticsearch Version 7.9.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.

We should choose the version of XAMPP that matches the above requirements. Then proceed to download and install.

Install XAMPP

3. Download and Install Composer

After downloading Magento, 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

4. Download Magento 2.4.7

Next, We download Magento 2.4.7 with Composer.

Go to htdocs folder on XAMPP installed directory.

Open Command Prompt an run:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.7-p3 magento247p3

5. Download and Install Elasticsearch

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

Run elasticsearch.bat as an administrator in the bin directory.

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

6. Configure extensions before installing

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

Find lines

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

replace to

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

by removing the “;” in front of.

Edit php.ini  php extensions

Expand memory_limit to 4G:

Expand memory_limit to 4G

Start Apache and MySQL in XAMPP Control Panel.

7. Fix Magento_Theme Error

To fix Module ‘Magento_Theme’ Error, go to xampp/htdocs/{magento-folder}/vendor/magento/framework/Image/Adapter/Gd2.php and replace the following function with the below code:

private function validateURLScheme(string $filename) : bool
   {
       $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
       $url = parse_url($filename);
       if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
           return false;
       }
       return true;
 }
Fix Magento_Theme Error In Magento 2.4.2

8. Create a new database

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

9. Configure hosts file

Go to C:\xampp\apache\conf\extra\httpd-vhosts.conf and add the following line to the last row.

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/magento_folder/pub"
    ServerName www.localhost.com
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

Go to C:\Windows\System32\drivers\etc\hosts and add the following line to the last row.

127.0.0.1 {your-url}
Note: You should run the editor tool as administrator to be able to confirm the change.

10. Install Magento 2.4.7

Go to the folder containing the Magento 2.4.7 created earlier, and open cmd.

Enter the command to install:

php bin/magento setup:install --base-url="http://magento247p3.magento2.com" --db-host="localhost" --db-name="magento247p3" --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

11. Execute Additional Tweaks After Installed

Go to app\etc\di.xml, search Symlink and replace with Copy.

Search Symlink in di.xml
Replace Symlink with Copy in di.xml

Next, fix Magento 2 admin blank page. In vendor\magento\framework\View\Element\Template\File\Validator.php, replace line 138 with:

$realPath = str_replace('\\', '/',$this->fileDriver->getRealPath($path));
Fix magento 2.4.2 admin blank page

Finally, run step by step these commands:

php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:di:compile

If you encounter an error related to PluginListGenerator.php while running the di:compile command, please refer to the following article: Fix Failed to Open Stream Error in PluginListGenerator.php in Magento 2.

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

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_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth

After fixing TwoFactorAuth, if you log in but the admin login page remains refreshing after clicking Sign In, you can refer to this article: Fix Magento 2 Admin Login Page Reloading Issue on Windows.

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

This is How To Install Magento 2.4.7 On XAMPP.

Follow us for more helpful article!

We hope this is useful blog for you.

Thank you for reading!

4.9 8 votes
Article Rating
Aaron LX

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
Ca Tca
Ca Tca
April 22, 2022 9:06 am

in step 10, i got the error:
mysql server has gone away

please advise

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