How to Install Magento 2 on xampp

11 Min | July 24, 2023

Magento 2 offers excellent features, powerful performance, robust security, and more. For the uninitiated, here’s a brief introduction: Magento 2 is a powerful open-source ecommerce content management system that is currently being used by the likes of Jaguar UK, Panasonic, Vitamix, and many more. The perfect way to host and develop Magento stores is on a cloud server. However, you can install Magento 2 on localhost using the XAMPP server.

This article will provide a step-by-step guide on how to install Magento 2 on XAMPP or how to run Magento in xampp.

XAMPP is a free and open-source cross-platform web server solution that enables you to run Magento 2 on your local machine for development and testing purposes.

Our guide is designed to assist everyone, from beginners to experienced ones, in successfully installing the latest Magento 2 version and exploring its powerful features. So, let’s get started.

Why Do You Need to Install Magento 2 on Localhost?

Regarding designers and developers, it’s always a good idea to set up Magento 2 on Localhost. Here are a few use cases for creating a Magneto 2 setup on your Windows machine:

  • If a new version, feature, or safe patch is launched, you can create a test environment to check if it’s stable enough for your websites.
  • Sometimes, you have to make some changes as per client requirements. If you change a production site (or live website), there’s a good chance that something might not work as expected. However, by creating a staging environment on localhost, you can make modifications, test them, and correct any issues. If everything works fine, you can upload it on the live server.
  • Setting up Magento locally allows you to test and work on different versions.

Magento 2 Installation Requirements

Specific requirements must be met to install Magento 2 on your server successfully. Therefore, before initiating the Magento 2 installation process, ensure your system meets all these requirements.

These are the requirements:

  • Apache/Ngnix 2.2 or 2.4 version
  • PHP 7.4.x or 8.1.x version.
  • MySQL/MariaDB 5.6.x, 5.7.x, or MariaDB
  • Elasticsearch 7.6.x or higher

Have you heard about the new tech stack powered by the OpenLiteSpeed web server? Learn all about it in this guide on the LOMP tech stack.

How to Install Magento 2 on XAMPP Server (Step-by-Step Guide)

Follow all the steps below to install Magento 2 using the XAMPP Server.

Installing XAMPP Server

To install and set up the XAMPP Server, follow these instructions.

  • First, you need to download XAMPP software; for that, go to the Apache Friends site and download the XAMPP software version that is compatible with your OS and meets your specific requirements.
XAMPP Download
  • After downloading it completely, run the software to install it on your system.
  • Click on the Next button.
Magento on Localhost - XAMPP Setup
  • Next, go with the default selection shown in the image and click on the Next button.
Magento on Localhost - XAMPP Components
  • The default location is C:xampp, but you can choose your preferred installation folder. Once you have made your selection, click on ‘Next.’
Magento on Localhost - XAMPP Setup
  • Click the ‘Next’ button.
Magento on Localhost - XAMPP
  • The setup is now ready to install. Please click the ‘Next‘ button.
Magento on Localhost - XAMPP Installation
  • Please wait as the setup wizard installs XAMPP on your computer. Once the installation is complete, the setup will be initiated.
Magento on Localhost - XAMPP Installation
  • After completing the setup, you will see the following message: “Do you want to start the Control Panel now?“You can proceed by clicking the “Finish” button to exit the setup and access the XAMPP control panel.
Magento on Localhost - XAMPP

Configuring XAMPP

Follow these steps to configure XAMPP for Magento 2 installation.

Start XAMPP

  • Launch the XAMPP control panel.
  • Start the Apache and MySQL services by clicking the “Start” button next to each service.
Magento on Localhost - XAMPP Control Panel
  • Ensure that the status indicator for both services changes to “Running.”
Magento on Localhost - XAMPP Control Panel

The green indicator means it is running.

Configure PHP

  • Click on the “Config” tab in the Apache section of the XAMPP control panel.
  • Locate the option for the PHP (php.ini) file and open it using a text or code editor.
Magento on XAMPP - php.ini
  • Inside the PHP (php.ini) file, find the following options and remove the semicolons before each row:
;extension=gd

;extension=intl

;extension=soap

;extension=sockets

;extension=sodium

;extension=xsl
  • Additionally, extend the memory to 4G by modifying the value of the memory_limit variable:
    • memory_limit = 4G
  • Once you have finished editing the file, save it and close the editor.
  • Finally, restart both Apache and MySQL services.
  • Ensure that both options are running correctly.
Magento on XAMPP

Let it run.

Create a database with phpMyAdmin

  • To create a database with phpMyAdmin, open your browser and enter/access the URL http://localhost/phpmyadmin.
  • Log in to the phpMyAdmin account by entering your username and password.
  • Go to the database section by clicking on the “Database” tab.
Magento on XAMPP - phpmyadmin
  • Enter the database name and click on the Create button.
Magento on XAMPP - Database Creation
  • Create a table, enter columns, and click the Go button.
Magento on XAMPP - Database Creation

The database is created successfully.

Download and Install Composer for Magento 2

  • To download and install Composer for Magento 2, go to getcomposer.org and download it.
Magento on XAMPP - Composer Installation
  • Get the Composer – setup.exe file.
Magento on XAMPP - Composer
  • Once the file is downloaded, double-click on it or run it.
  • Select a mode to install. “Install for all users” is recommended, so I chose it here.
Magento on XAMPP - Composer Install Process
  • Click on the Next.
Magento on XAMPP - Composer Install Process
  • Locate the PHP file address in the XAMPP folder and enter the location here. Then, check the “add this PHP to your path” box and click on the next.
Magento on XAMPP - Composer Install Process
  • It is optional to add a proxy URL so you can skip it and click on the next.
Magento on XAMPP - Composer Install Process
  • Last but not least, click on the Install button to complete the final step of the installation process.
Magento on XAMPP - Composer System Review
  • Click on the next.
Magento on XAMPP - Composer Installation
  • Complete the installation by clicking on the Finish button.
Magento on XAMPP - Composer Installation Is Done
  • To ensure that Composer has been installed correctly, launch the Command Prompt.
  • Run the Composer command to verify the installation status and check for potential issues.
Magento on XAMPP - Composer on CLI

Here you go! We have successfully installed the Composer on our system.

Download and Install Elasticsearch for Magento 2

  • As it is a prerequisite to installing Elasticsearch on your system for Magento 2 installation, go to https://www.elastic.co/downloads/past-releases/elasticsearch-7-6-0 and download it.
  • Once you have downloaded the Elasticsearch package on your system, extract it.
  • Go to the command prompt and navigate to the folder where you have extracted the elastic search file by running the cd command.
cd directory-path
Magento on XAMPP - Elasticsearch Installation
  • Once you are in the Elasticsearch folder, execute this command to install Elasticsearch on your system.
.binelasticsearch.bat
Magento on XAMPP - Elasticsearch Installation
  • Once the execution is done, go to your browser and enter “local:9200” in the search bar to check the availability of Elasticsearch on port:9200.
Magento on XAMPP - Elasticsearch Installation Verification

Congratulations! We have successfully installed Elasticsearch on our system.

Download Magento 2 using Composer

To download Magento 2 using Composer, open the command prompt and navigate to the directory where you want to download your Magento 2 application using the “cd” command. Run the below command to navigate to the desired directory:

cd directory-path

For example, I want to download Magento 2 application in the magentoprojectshtdocs directory of the xampp folder, so I will run this command:

cd C:xampphtdocsmagentoprojects
Magento Installation using Composer
  • Now, run this command to install the Magento 2 application of your required version using Composer.
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.5
Magento Installation using Composer

While running the above command, it will ask for Magento repository authentication, i.e. Username and Password.

You must sign in to your Magento marketplace account and create an access key to get authentication credentials. If you do not have a Magento marketplace account, create one first.

Follow these steps to create an access key and get authentication credentials.

Magento Installation using Composer - Access Keys on Adobe Commerce
  • Once on the access keys page, click the “Create A New Access Key” button.
Magento Installation using Composer - Access Keys Creation
  • Enter a name for the Access Key and click on the “OK” button.
Magento Installation using Composer - Access Keys Creation

Here you go! The authentication credential has been created.

You can see two keys here “Public Key” and “Private Key.” The public key will be used as a username, and the private key will be used as a password.

Magento Installation using Composer - Access Keys Details
  • Copy the Public key and enter it on the terminal as username.
Magento Installation using Composer - Using Public Key on Terminal
  • Copy the Private key and enter it on the terminal as the password.
Magento Installation using Composer - Private Key as Password
  • It will ask you to store the credentials for the Magento repository in your system’s authentication file. So, if you want to save it for the future, enter “Y,” and if you do not want to save it, enter “N.”
  • It will start processing the download Magento command.
Magento Installation using Composer - Downloading

Congratulations! We have downloaded the Magento application using Composer successfully.

Magento Installation using Composer

Install Magento 2 on localhost Using Command Line

Before executing the Magento installation command, open the Gd2.php file. Go to vendormagentoframeworkImageAdapterGd2.php, you can find it in your project directory.

Replace this line of code:

 if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes))
Magento Installation using CLI or Command Prompt

With this code:

if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename))
Magento Installation using CLI

unable to apply data patch magento\theme\setup\patch\data\registerthemes for module magento_theme. original exception message: wrong file

Note: If you do not change this line of code, you will get an error “Unable to apply data patch MagentoThemeSetupPatchDataRegisterThemes for module Magento_Theme. Original exception message: Wrong file.

Magento Installation using CLI - Fixing Errors
  • Once you are done with these changes, open your command prompt and run this command:
php bin/magento setup:install --base-url="http://localhost/project-community-edition/" --db-host="localhost" --db-name="magento2app" --db-user="root" --admin-firstname="admin" --admin-lastname="panel" --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
Magento Installation using CLI

Please note the following instructions to configure your Magento 2 installation properly:

  • Assign the base URL according to your installation path.
  • Make sure to record the admin username and password for future reference.
  • Do not use the Elasticsearch port.
  • Now, replace the default values with your specific information:

–base-url: Use your Magento 2 installation folder path.

–db-name: Enter your desired database name when creating the database.

–db-password: Set your preferred database password.

–db-user: Create a new database user with full permissions or use the default root user.

–db-password: Specify the password for your database user. If you use the ‘root’ database user, leave this field blank.

–admin-firstname: Provide the first name of the admin user.

–admin-lastname: Provide the last name of the admin user.

–admin-email: Enter the email address of the admin user.

–admin-user: Choose a username for logging into the Admin Panel.

–admin-password: Set the password for logging into the Admin Panel.

–language: Select the desired language for your Admin Panel and storefront. Use the language code, e.g., en_US.

–admin-email: Replace with your email address.

–currency: Set the default currency for your storefront. You can find a list of supported currencies and their codes by running php bin/magento info:currency:list.

–timezone: Change to your local timezone. Refer to the list of supported timezones for available options.

–url-rewrites: Set to 1 to enable Web Server Rewrites, which can help your site ranking.

–backend-frontname: Set your Admin URL. If you omit this parameter, Magento will generate a random URL for your Magento Admin path (e.g., admin_jkhgdfq).

–search-engine: Specify the version of Elasticsearch you want to use for this Magento installation. The default is Elasticsearch 7.

–elasticsearch-host: Provide the hostname or IP address where Elasticsearch runs. The default is localhost.

–elasticsearch-port: Specify the port number that Elasticsearch is listening to. The default is 9200.

Note that other values are optional and can be changed later.

  • Once you have completed the configuration, Composer 2 will begin installing Magento 2. The installation process will take some time to be done.
Magento Installation using CLI - Installation

When you see “SUCCESS” prompt on your screen, you have done the installation process correctly. We have successfully installed Magento 2 on localhost using XAMPP Server.

Now, you are required to execute the following commands.

php bin/magento indexer:reindex

php bin/magento setup:upgrade

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

php bin/magento cache:flush

You can make any changes to your Magento 2 store and customize it according to your needs or requirements.

To access your Magento store, enter this URL localhost/projectdirectoryname/pub/ or use the base URL you previously set for ‘base-url’ during the installation into the browser.

To access your Magento’s admin panel/dashboard, enter this URL http://localhost/projectdirectoryname/pub/admin into the browser.

Conclusion

You have successfully learned to install Magento 2 on localhost using the XAMPP server and Composer. When you want to launch your online store, you can rely on Devrims Managed Magento Hosting to optimize performance, boost sales, and handle all server-side management tasks seamlessly.

You can fully concentrate on building an interactive Magento 2 store, as Devrims will handle all technical issues and tasks. Feel free to ask if you face any issues during the installation process.

Blazing Fast Magento Hosting

Enjoy Six Days Free Trial Account without any feature restriction and payment details to experience a true Managed Cloud Hosting Platform.

SIGN UP FOR FREE

The Author

Anmol is a dedicated technical content writer known for her practical approach. She believes in experiencing processes firsthand before translating them into insightful content. Additionally, she is good at WordPress development and skills of digital forensics and cybersecurity. Beyond her professional endeavors, she enjoys playing sports games, particularly table tennis and badminton, valuing the balance between mental and physical agility.

Scroll to Top