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 magentoYou will need the auth.json key from Magento Marketplace.
- Configure the web server, setting DocumentRoot to
pub/(not the project root) - Alternatively, during development, place
magentoinhtdocs/and configure an alias pointing topub/ - Use phpMyAdmin to create the database
magento_local - Install via command line or access http://localhost/magento to run the Setup Wizard
Database Example
| Item | Value |
|---|---|
| Host | localhost |
| Database | magento_local |
| User | root |
Common Paths
| Path | Description |
|---|---|
/ (pub root) | Store frontend |
/admin | Admin backend |
bin/magento | CLI (cache, compile, deploy) |
Local Development Commands
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento indexer:reindexDeveloper 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.