Installation
Magento is installed in two steps: Composer downloads the files, and the setup:install command creates the database tables and the first administrator. By this point PHP, MySQL and OpenSearch must be running, and MySQL must contain an empty database, for example shop.
Access keys
Magento packages live in the repo.magento.com repository. It requires keys: you create them for free in your account on the Adobe Commerce Marketplace site, in the Access Keys section. Composer asks for a username and a password — these are the public and the private key.
Creating the project
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition shop
cd shopComposer creates the shop folder and downloads the core into it. This takes a few minutes.
The installer
bin/magento setup:install \
--base-url=http://shop.test/ \
--db-host=localhost --db-name=shop --db-user=root --db-password=secret \
--admin-firstname=Anna --admin-lastname=Smith --admin-email=admin@example.com \
--admin-user=admin --admin-password=Secret123 \
--backend-frontname=admin \
--search-engine=opensearch --opensearch-host=localhost --opensearch-port=9200The command creates the tables, the admin administrator and the app/etc/env.php settings file. At the end it prints a success message and the admin panel address.
| Option | What it sets |
|---|---|
--base-url | The shop address, with a trailing slash |
--db-* | The database connection |
--admin-* | The first administrator account |
--backend-frontname | The admin address: admin gives /admin |
--opensearch-* | The search service connection |
Web server
The site root must be the pub folder inside the project, not the project itself. For Nginx the project ships a ready-made sample configuration — the nginx.conf.sample file.
Checking
Open http://shop.test/ — an empty storefront with the Luma theme appears. The admin panel is at http://shop.test/admin.
Two-factor login
In Magento 2.4 the admin login requires a second step — a code from an app. On a local copy this gets in the way, so the login modules are usually disabled:
bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth
bin/magento cache:flushAfter that the panel lets you in with a username and a password. Do not disable these modules on a production server.
Sample products
bin/magento sampledata:deploy
bin/magento setup:upgradeThe first command downloads the sample modules, the second one installs them. Products and categories appear in the catalog — they are handy for trying the code from the following lessons.
Common mistake
The installer stops with a message about an unavailable search service when OpenSearch is not running or the address is wrong. Check it before installing: the curl http://localhost:9200 request must return JSON with a version number.