How to Install Magento 2 on XAMPP – Complete Step-by-Step Guide
🖥️ Master Local Magento 2 Development
Learn how to set up Magento 2 on XAMPP for efficient local development, testing, and debugging before going live.
Introduction
Installing Magento 2 on XAMPP is ideal for developers who want to test extensions, themes, or custom code locally before deploying to a live server. This comprehensive guide covers everything from prerequisites to post-installation optimisation, ensuring you have a robust local development environment.
🎯 Why Choose XAMPP for Magento 2 Development?
- All-in-One Solution: Includes Apache, MySQL, PHP, and phpMyAdmin in one package
- Easy Setup: Simple installation process for Windows, Mac, and Linux
- Cost-Effective: Completely free and open-source
- Developer-Friendly: Perfect for testing before production deployment
- Isolated Environment: Safe testing without affecting live sites
Prerequisites
Before installing Magento 2 on XAMPP, ensure your system meets these requirements:
System Requirements
💻 Operating System
- Windows 10/11 (64-bit)
- macOS 10.14+
- Linux (Ubuntu 18.04+)
🔧 Software Requirements
- XAMPP (latest version)
- PHP 8.1 or 8.2
- MySQL 8.0+
- Apache 2.4+
⚡ Hardware Requirements
- At least 4GB RAM (8GB+ recommended)
- 10GB+ free disk space
- Quad-core processor recommended
📦 Additional Tools
- Composer (for dependency management)
- Magento Marketplace account
- Text editor (VS Code, PHPStorm)
Step-by-Step Installation Guide
Step 1: Install and Configure XAMPP
1.1 Download XAMPP
Download the latest XAMPP from Apache Friends.
💡 Pro Tip: Choose the version with PHP 8.1 or 8.2 for optimal Magento 2.4.x compatibility.
1.2 Install XAMPP
Run the installer and follow the setup wizard. Install to the default location (C:\xampp
on Windows).
⚠️ Important: Run the installer as Administrator on Windows to avoid permission issues.
1.3 Start Services
Launch XAMPP Control Panel and start Apache and MySQL services.
Verify services are running (green "Running" status in control panel).
1.4 Create Database
Open phpMyAdmin by clicking "Admin" next to MySQL or navigate to:
http://localhost/phpmyadmin
Create a new database for Magento 2 (e.g., magento2_db
).
Step 2: Configure PHP Settings
🔧 Essential PHP Configuration
Edit the PHP configuration file at C:\xampp\php\php.ini
and update these settings:
memory_limit = 2G
max_execution_time = 1800
max_input_vars = 1000
zlib.output_compression = on
; Enable required extensions
extension=gd2
extension=intl
extension=openssl
extension=soap
extension=sockets
extension=zip
extension=bcmath
Important: Restart Apache after making these changes.
Step 3: Download Magento 2 via Composer
3.1 Navigate to htdocs
Open Command Prompt (as Administrator) and navigate to XAMPP's htdocs folder:
cd C:\xampp\htdocs
3.2 Install Magento 2
Run the Composer command to install Magento 2:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
Enter your Magento Marketplace credentials when prompted.
🔑 Getting Magento Marketplace Keys
- Visit Magento Marketplace
- Sign in or create an account
- Go to "My Profile" → "Access Keys"
- Create new access keys
- Use Public Key as username, Private Key as password
Step 4: Run Magento 2 Installation
4.1 Access Installation Wizard
Open your browser and navigate to:
http://localhost/magento2
The Magento Setup Wizard should load automatically.
4.2 Database Configuration
Enter the following database details:
- Database Name:
magento2_db
(or your chosen name) - Username:
root
(default XAMPP MySQL user) - Password: Leave empty (default XAMPP setup)
- Host:
localhost
4.3 Admin Account Setup
Create your admin account with:
- Admin username (avoid "admin" for security)
- Strong password (8+ characters)
- Admin email address
- First and last name
Step 5: Post-Installation Steps
5.1 Enable Developer Mode
Navigate to your Magento directory and enable developer mode for easier debugging:
cd C:\xampp\htdocs\magento2
php bin/magento deploy:mode:set developer
5.2 Clear Cache
php bin/magento cache:flush
5.3 Reindex Data
php bin/magento indexer:reindex
🎉 Installation Complete!
Your Magento 2 installation is now ready. Access your store at:
- Frontend:
http://localhost/magento2
- Admin Panel:
http://localhost/magento2/admin
FAQs – Magento 2 on XAMPP
1. Why use XAMPP for Magento 2?
- ✅ Free & easy setup for local development
- ✅ Includes Apache, MySQL, PHP in one package
- ✅ Perfect for testing before production deployment
- ✅ Isolated development environment
2. What if I get a "PHP extensions missing" error?
Enable these extensions in C:\xampp\php\php.ini
:
extension=gd2
extension=intl
extension=openssl
extension=soap
extension=bcmath
extension=zip
Restart Apache after making changes.
3. How do I fix "localhost refused to connect"?
- Ensure Apache is running in XAMPP Control Panel
- Check if Magento is in the correct htdocs folder
- Verify port 80 isn't blocked by antivirus/firewall
- Try
http://127.0.0.1/magento2
instead
4. Can I install Magento 2 without Composer?
Yes, you can download the archive from Magento, but Composer is strongly recommended for:
- Automatic dependency management
- Easy updates and patches
- Extension installation capabilities
5. How to speed up Magento 2 on XAMPP?
- Use OPcache (
opcache.enable=1
in php.ini) - Enable CSS/JS merging in Magento Admin
- Increase PHP memory limit to 2G+
- Disable Xdebug when not debugging
- Use an SSD for XAMPP installation
Troubleshooting Common Issues
🚨 Common Problems & Solutions
- Installation hangs: Increase PHP max_execution_time to 1800 seconds
- White screen of death: Check error logs in xampp/apache/logs/error.log
- Permission denied errors: Run Command Prompt as Administrator
- Composer timeout: Run
composer config --global process-timeout 2000
- Database connection failed: Verify MySQL is running and credentials are correct
Conclusion
Installing Magento 2 on XAMPP creates a powerful local development environment that mirrors production conditions. This setup allows you to develop, test, and debug efficiently before deploying to live servers. Follow this guide carefully to avoid common pitfalls and enjoy smooth local development.
Remember to regularly update your XAMPP components and Magento installation to stay current with security patches and new features.
🚀 Ready to Enhance Your Magento Store?
Now that you have Magento 2 running locally, explore our free extensions to add powerful functionality to your development environment. Test new features safely before implementing on production!