Installing Magento on localhost

Local installation of the Magento open-source e-commerce platform for developing and debugging store themes and modules at http://localhost/magento.


Magento Open Source (formerly Magento CE) is a fully-featured PHP e-commerce platform suitable for B2C/B2B online stores. Local installation can be resource-intensive, so it is recommended to allocate sufficient memory and use Composer.

Prerequisites

  • PHP 8.1+ or 8.2 (according to the official compatibility matrix)
  • MySQL 8.0+ or MariaDB
  • Elasticsearch or OpenSearch (required for search in Magento 2.4+)
  • Composer 2
  • Recommended RAM ≥ 8GB (for local full stack)

Installation Steps (Composer)

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

You will need the auth.json key from Magento Marketplace.

  1. Configure the web server, setting DocumentRoot to pub/ (not the project root)
  2. Alternatively, during development, place magento in htdocs/ and configure an alias pointing to pub/
  3. Use phpMyAdmin to create the database magento_local
  4. Install via command line or access http://localhost/magento to run the Setup Wizard

Database Example

ItemValue
Hostlocalhost
Databasemagento_local
Userroot

Common Paths

PathDescription
/ (pub root)Store frontend
/adminAdmin backend
bin/magentoCLI (cache, compile, deploy)

Local Development Commands

php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento indexer:reindex

Developer mode: php bin/magento deploy:mode:set developer

Frequently Asked Questions

Slow installation / Insufficient memory
Increase PHP memory_limit (e.g., to 2G); add swap; use COMPOSER_MEMORY_LIMIT=-1.

Elasticsearch not running
Magento 2.4+ requires Elasticsearch/OpenSearch to be installed locally or refer to the official Docker solution.

Static content 404
Run setup:static-content:deploy; in developer mode, you can symlink static files.

Summary

The typical local address for Magento is http://localhost/magento (the web root should point to pub/), with high resource demands, suitable for professional development of e-commerce themes and modules.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run