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.
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.
We see that XAMPP version 7.4.12 conforms to the requirements set forth above, we proceed to download and install it.
3. Download Magento 2.4.1
Next, We download the version Magento 2.4.1 include sample data.
Unzip it to the XAMPP’s htdocs directory.
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.
At the time of installation, choose the correct path to the php.exe of XAMPP just installed.
You can check if the Composer installation was successful or not by opening the Command Prompt with administrator privileges. Next, check with composer command.
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.
Run elasticsearch.bat as an administrator in the htdocs/elasticsearch-7.6.2/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=xsl
replace to
extension=intl
extension=soap
extension=sockets
extension=xsl
by removing the “;” in front of.
Restart Apache and MySQL in XAMPP Control Panel.
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.
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.
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.
After the installation, will display like this:
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”.
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:
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!
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.