How to Install Magento 2.4.9 on Windows Using XAMPP and Composer (Step-by-Step Guide)

How to Install Magento 2.4.9 on Windows Using XAMPP and Composer (Step-by-Step Guide)

Introduction

In this tutorial, we will learn how to install Magento Open Source 2.4.9 on Windows using XAMPP and Composer.

We will cover the complete installation process, including environment setup, PHP configuration, Composer installation, database configuration, Magento package installation, and storefront access.

Each step includes commands, configuration instructions, and screenshots to help developers follow along easily.

Table of Contents

  1. Prerequisites for Installing Magento 2.4.9 on Windows
  2. Download and Install XAMPP
  3. Install and Configure Composer
  4. Install and Configure OpenSearch 3
  5. Configure PHP for Magento 2.4.9
  6. Configure MySQL Database
  7. Download Magento 2.4.9 Using Composer
  8. Install Magento Using Command Line
  9. Configure Apache Virtual Host
  10. Access Magento Storefront and Admin Panel
  11. Troubleshooting Common Installation Errors
  12. Conclusion

1. Prerequisites for Installing Magento 2.4.9 on Windows

Before installing Magento Open Source 2.4.9 on Windows, we need to prepare the development environment and ensure that all required software and dependencies are available.

Magento uses several technologies to manage its application, database, search functionality, and package dependencies. We will use XAMPP for the local Apache and PHP environment, Composer to download Magento, and OpenSearch for catalog search.

The following software is required for this installation:

SoftwareRequired VersionPurpose
WindowsWindows 10/11 64-bitOperating system
XAMPPCompatible PHP 8.5 buildLocal Apache and PHP environment
PHP8.5Magento application runtime
Composer2.10PHP dependency management
MySQL8.4Database management
OpenSearch3.xCatalog search functionality
ApacheXAMPP bundled versionLocal web server

Note: Magento 2.4.9 also supports MariaDB 12.3. However, XAMPP bundles MariaDB rather than MySQL, so check its exact version before using it. For this tutorial, we will use a separately installed MySQL 8.4 database if the bundled MariaDB version is incompatible.

2. Download and Install XAMPP on Windows

XAMPP is a local development environment that provides Apache, PHP, MariaDB and phpMyAdmin. It allows developers to run PHP applications locally without configuring a web server manually.

In this section, we will download and install XAMPP on Windows and verify that Apache and PHP are working correctly.

Download XAMPP

Download the Xampp installer to your computer : Click Here to Download XAMPP 8.5.12

Install XAMPP

  1. Download and Run the downloaded installer.

  2. If Windows displays a User Account Control prompt, allow the installer to proceed.

  3. In the Select Components screen, make sure the following components are selected:
      • Apache
      • MySQL (XAMPP bundles MariaDB as its database server)
      • PHP
      • phpMyAdmin

  4. Choose an installation directory. For this tutorial, we will use:C:\xampp
  5. Complete the installation.

Start Apache and the Database Server

  1. Open the XAMPP Control Panel.
  2. Click Start next to Apache.
  3. Click Start next to MySQL.
  4. Confirm that both services show a green running status.

If either service fails to start, check whether another application is already using its port. Apache commonly uses ports 80 and 443, while the database server commonly uses port 3306.

Verify the PHP Version

Open Command Prompt and run:

php -v

You should see PHP 8.5.12 in the output.

3. Install and Configure Composer on Windows

Composer is a dependency management tool for PHP. It helps developers install, update and manage the PHP libraries and packages required by an application.

Magento uses Composer to download its core application packages, third-party dependencies and extensions.

In this section, we will install Composer on Windows and configure it to use the PHP executable bundled with XAMPP.

3.1 Download Composer

Let’s Download Composer: Click Here to Download Composer

3.2 Install Composer

Once the download is complete, follow these steps:

Step 1: Double-click Composer-Setup.exe to start the installation.

Step 2: Select the installation type.

Choose the recommended option:

Install for all users (recommended)

Click Next to continue.

Step 3: The installer will ask you to locate the PHP executable.

Select the PHP executable from your XAMPP installation directory.

For example:

C:\xampp\php\php.exe

Click Next to continue.

Important: Make sure you select the PHP executable from your XAMPP installation. This ensures Composer uses the same PHP version as your local development environment.

Step 4: Review the PHP configuration and proxy settings.

If you are not using a proxy server, leave the proxy configuration disabled and continue.

Step 5: Review the installation settings and click Install.

Step 6: Wait for Composer installation to complete.

Step 7: Click Finish to close the installer.

Close any previously opened Command Prompt windows and open a new Command Prompt so that the updated system PATH is loaded.

3.3 Verify Composer Installation

After completing the installation, we need to verify that Composer is installed and working correctly.

Step 1: Open Command Prompt.

Step 2: Execute the following command:

composer --version

You should see output displaying the installed Composer version.

Since we are setting up Magento 2.4.9 on Windows using XAMPP, we will use Composer 2.10.3 for this installation to maintain a consistent and reproducible development environment.

Run below command prompt using Administrator Previlege:

composer self-update 2.10.3

You will see the output as below:

4. Install and Configure OpenSearch 3

Step 1: Download OpenSearch 3:

Lets download OpenSearch 3 : Click Here to download OpenSearch 3

Step 2: Extract OpenSearch

After downloading:

  1. Open your Downloads folder.

  2. Right-click the ZIP file.

  3. Select Extract All.

Extract it to:

C:\xampp\htdocs\opensearch-3.10.0

Step 3: Configure OpenSearch

Open:

C:\xampp\htdocs\opensearch-3.10.0\config\opensearch.yml

For local Magento development, we’ll disable the security plugin to simplify the connection.

Add these settings at the end of the file:

cluster.name: magento-cluster

node.name: magento-node

network.host: 127.0.0.1

http.port: 9200

discovery.type: single-node

plugins.security.disabled: true

Save the file.

Imp Note: This is for Development only. This configuration disables authentication and HTTPS. Keep OpenSearch bound to localhost and never expose this configuration to a public network. Production requires proper security configuration.

Step 4: Configure Java heap memory

Open:

C:\xampp\htdocs\opensearch-3.10.0\config\jvm.options

Find:

-Xms1g
-Xmx1g

For a local development environment, 1 GB is a reasonable starting point if your computer has sufficient memory.

Keep both values equal.

Save the file.

Step 5: Start OpenSearch

Open Command Prompt as Administrator.

Execute:

cd C:\xampp\htdocs\opensearch-3.10.0\bin

Start OpenSearch:

opensearch.bat

Wait until OpenSearch finishes initializing. Keep this terminal window open while using Magento.

Step 6: Verify OpenSearch installation

Open another Command Prompt window.

Execute:

curl.exe http://localhost:9200

You should receive a JSON response similar to:

5. Configure PHP for Magento 2.4.9

PHP is the core programming language used by Magento. Before installing Magento Open Source 2.4.9, we need to configure PHP and enable the required PHP extensions.

Since we are using XAMPP on Windows, we will configure PHP using the php.ini configuration file available in the XAMPP installation directory.

5.1 Locate the PHP Configuration File

First, we need to locate the php.ini file used by XAMPP.

By default, the PHP configuration file is located at:

C:\xampp\php\php.ini

Follow these steps:

  1. Open the XAMPP installation directory.

  2. Navigate to the php folder.

  3. Locate the php.ini file.

  4. Open the file using Notepad or Visual Studio Code.

Alternatively, you can open the PHP configuration file directly from the XAMPP Control Panel.

Click the Config button next to Apache and select PHP (php.ini).

5.2 Enable Required PHP Extensions

Magento requires several PHP extensions to perform operations such as database connectivity, image processing, encryption, XML processing and HTTP requests.

Open the php.ini file and locate the following extensions.

The extensions required by Magento Open Source 2.4.9 include:

The following PHP extensions must be available:

PHP ExtensionPurpose
bcmathMathematical calculations
ctypeCharacter type checking
curlHTTP requests and API communication
domXML and HTML document processing
fileinfoFile type detection
ftpFTP operations
gdImage processing
intlInternationalization
mbstringMultibyte string handling
opensslEncryption and security
pdo_mysqlMySQL database connectivity
simplexmlXML processing
soapSOAP API communication
socketsNetwork socket operations
sodiumCryptographic operations
xslXML transformations
zipZIP archive handling

Some extensions, such as ctype, dom, hash, iconv, json, libxml, pcre, reflection, spl, tokenizer, xmlwriter and zlib, are already provided by PHP or compiled into it. They do not necessarily require separate entries in php.ini.

How to enable PHP extensions

Step 1: Open the php.ini file.

Step 2: Search for the extension you want to enable.

For example:

;extension=curl

Step 3: Remove the semicolon (;) from the beginning of the line.

extension=curl

Step 4: Repeat this process for any required extensions that are currently disabled.

For example:

extension=bcmath
extension=curl
extension=ftp
extension=gd
extension=intl
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=soap
extension=sockets
extension=sodium
extension=xsl
extension=zip

Make sure the corresponding extension DLL files are available in the XAMPP PHP ext directory.

Step 5: Save the php.ini file.

5.3 Configure PHP

Magento requires sufficient PHP memory to execute installation commands, compile code and generate static content.

max_execution_time=18000
max_input_time=1800
memory_limit=4G

5.4 Enable and Configure OPcache

OPcache improves PHP performance by storing precompiled PHP bytecode in memory.

Locate the OPcache configuration in php.ini.

Make sure the following settings are enabled:

opcache.enable=1
opcache.enable_cli=1
opcache.save_comments=1

The opcache.save_comments setting must remain enabled because Magento uses PHP code comments for code generation.

5.5 Save Changes and Restart Apache

After updating the PHP configuration:

  1. Save the php.ini file.
  2. Open the XAMPP Control Panel.
  3. Stop Apache.
  4. Start Apache again.

This ensures Apache loads the updated PHP configuration.

6. Configure MySQL Database for Magento 2.4.9

Magento requires a database to store important application information, including products, categories, customers, orders, configurations and website settings.

In this section, we will configure the database required for our Magento Open Source 2.4.9 installation using XAMPP on Windows.

n Xampp interface, open PHPmyadmin by clicking on Admin button to open phpmyadmin (you can also type: localhost/phpmyadmin/ in browser to access phpmyadmin)

On phpmyadmin page, click on New => type database name => click on Create to create a new database. For example, I create magento2 database here

By default, Xampp does not set a password for MYSQL, so we will need to create a new root password for mysql.

On Xampp, click on Shell button to open command interface

Next, input the following command to change mysql root password

mysqladmin.exe -u root password yourpassword

Replace yourpasswordwith your desired password. I put root as password.

Now, to use phpmyadmin, you will also need to enter the new password. To make phpmyadmin automatically login with your new password, go to C:\xampp\phpMyAdmin\config.inc.php and insert your new password here

7. Download and Install Magento 2.4.9 Using Composer

Composer is used to download Magento Open Source and manage its required PHP packages and dependencies.

7.1 Download Magento 2.3.9 using composer

In command prompt, cd C:\xampp\htdocs,

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.9 magento2

magento2 – is the folder name

If the Private and Public keys asked then follow step 7.2 as given below.

7.2 Generate Composer Authentication Keys

Create an account on Magento marketplace and go to https://marketplace.magento.com/customer/accessKeys/ to get private and public access key.

Follow these steps:

  1. Click your account name in the top-right corner.

  2. Select My Profile.

  3. Navigate to the Marketplace tab.

  4. Open Access Keys.

  5. Click Create a New Access Key.

  6. Enter a name for your key pair, such as Magento249-Windows.

  7. Click OK.If Private and Public key asked then follow below steps:

Adobe will generate two authentication keys:

  • Public Key: Used as the Composer username.

  • Private Key: Used as the Composer password

    Successful download looks like this

Now, see the magento2 folder with all files and folders.

 

7.3 Set Document Root

We need to set document root, to do this go to file C:\xampp\apache\conf\extra\httpd-vhosts.conf

Add this content in the bottom of the file.

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/magento2/pub"
    ServerName yourname.magento.com
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

Where,

DocumentRoot "C:/xampp/htdocs/magento2/pub"=> location of the magento2 folder path

yourname.magento.com – this is the base url which you can set as per your wish. Ex: – sonal.magento.com

Now, Open notepad with “Run as administrator”.

lets open C:\Windows\System32\drivers\etc\hosts file in notepad and add the below line at the bottom of the file.

 127.0.0.1  yourname.magento.com

In my case it is,

127.0.0.1 sonal.magento.com

Restart apache to apply php settings by click on apache Stop and Start button on XAMPP

 

8. Install Magento 2.4.9 Using Command Line

After downloading Magento 2.4.9 using Composer and configuring the database and OpenSearch, we can now install Magento using its command-line installer.

Magento 2.4.9 does not use the old web-based installation wizard. The installation is performed using the bin/magento setup:install command.

Step 8.1: Open the Magento Installation Directory

Open Command Prompt and navigate to your Magento project directory:

cd C:\xampp\htdocs\magento2

Make sure you are inside the directory containing the bin folder.

Step 8.2: Run the Magento Installation Command

Run the following command to install Magento 2.4.9:

php bin/magento setup:install ^
--base-url=http://yourname.magento.com/ ^
--db-host=127.0.0.1 ^
--db-name=magento2 ^
--db-user=magento_user ^
--db-password=YOUR_DATABASE_PASSWORD ^
--admin-firstname=Store ^
--admin-lastname=Admin ^
--admin-email=admin@example.com ^
--admin-user=admin ^
--admin-password=YOUR_STRONG_ADMIN_PASSWORD ^
--language=en_US ^
--currency=USD ^
--timezone=Asia/Kolkata ^
--use-rewrites=1 ^
--search-engine=opensearch ^
--opensearch-host=127.0.0.1 ^
--opensearch-port=9200 ^
--opensearch-index-prefix=magento249 ^
--opensearch-timeout=15 Example: php bin/magento setup:install ^ --base-url=http://sonal.magento.com/ ^ --db-host=127.0.0.1 ^ --db-name=magento2 ^ --db-user=root ^ --db-password=root ^ --admin-firstname=Store ^ --admin-lastname=Admin ^ --admin-email=admin@example.com ^ --admin-user=admin ^ --admin-password=admin@123 ^ --language=en_US ^ --currency=USD ^ --timezone=Asia/Kolkata ^ --use-rewrites=1 ^ --search-engine=opensearch ^ --opensearch-host=127.0.0.1 ^ --opensearch-port=9200 ^ --opensearch-index-prefix=magento249 ^ --opensearch-timeout=15

Important: Replace YOUR_DATABASE_PASSWORD with the password configured for your MySQL database user. Replace YOUR_STRONG_ADMIN_PASSWORD with a strong password for your Magento Admin account. Update the email address as well.

Example:

 php bin/magento setup:install ^ --base-url=http://yourname.magento.com/ ^ --db-host=127.0.0.1 ^ --db-name=magento2 ^ --db-user=root ^ --db-password=root ^ --admin-firstname=Store ^ --admin-lastname=Admin ^ --admin-email=admin@example.com ^ --admin-user=admin ^ --admin-password=admin@123 ^ --language=en_US ^ --currency=USD ^ --timezone=Asia/Kolkata ^ --use-rewrites=1 ^ --search-engine=opensearch ^ --opensearch-host=127.0.0.1 ^ --opensearch-port=9200 ^ --opensearch-index-prefix=magento249 ^ --opensearch-timeout=15

Ensure that the database name, username, password, and database host match the settings configured in the previous database section.

Also, make sure OpenSearch is running and accessible on port 9200 before starting the installation.

Magento installation shows below screen

Error1:

In PatchApplier.php line 169:

Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file

In Gd2.php line 60: Wrong file

Solution:

Here Image Adapter try opens to image files (‘open function in Gd2.php line 70). validateURLScheme function return false always because it checking ‘URL’ format but local files not valid for this format, so it returns false.

Find validateURLScheme function in C:\xampp\htdocs\magento2\vendor\magento\framework\Image\Adapter\Gd2.php file. at line 92.

Replace line line 96 with below

if ($url && isset($url[‘scheme’]) && !in_array($url[‘scheme’], $allowed_schemes) && !file_exists($filename)) {

Save the file and again run the magento2 install command in the command prompt.

Once the complete installation finished, you will see below screen

Now lets hit the Url, in my case it is – http://sonal.magento.com/

you will see below screen:

Here’s how to fix this:

Go to: C:\xampp\htdocs\magento2\vendor\magento\framework\View\Element\Template\File

Edit Validator.php using a text editor and find this line:

instead of the line

strpos($realPath, $directory)

use

strpos($path, $directory)

Save the File.

Then,

Open up app/etc/di.xml in the editor,

– Find the path “Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink” and replace to “Magento\Framework\App\View\Asset\MaterializationStrategy\Copy”

Save the file.

Next, you will need to run these command to upgrade the database and deploy static view files

C:\xampp\htdocs\magento2>

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

Now reload your website and you will see the your new Magento 2 website on localhost.

Sonal Motghare-Balpande

About Sonal Motghare-Balpande Sonal Motghare-Balpande is an eCommerce technology professional with 14+ years of experience working with Magento, PHP and eCommerce platforms. Over the years, she has worked on real-world eCommerce stores, helping businesses and development teams solve technical problems, improve performance, upgrade and maintain Magento stores, and make practical technology decisions. Through TheCoachSMB, Sonal shares what she has learned from working on real eCommerce projects — from Magento development and troubleshooting to performance, SEO, architecture, upgrades and day-to-day technical challenges. Her approach is practical and experience-driven: Learn the technology. Understand the problem. Make the right decision. The goal is simple: make complex eCommerce technology easier to understand and help developers and eCommerce professionals avoid costly technical mistakes. Have a question about Magento or eCommerce? If you're working through a Magento problem, learning eCommerce development, or trying to make an important technology decision, Ask Sonal. Connect with Sonal WhatsApp: +91 702-050-0374 Email: support@thecoachsmb.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Select your currency
USD United States (US) dollar