In short
bin/magento setup:install creates the database tables, the admin user and app/etc/env.php in one run. You need the base URL and the four database options; the rest sets the admin path, language, currency, time zone, OpenSearch and, in 2.4.9, Valkey for sessions and cache.
This is part 5 of our Magento installation series. Part 4 was which PHP version Magento 2 needs. Run the command from the Magento root folder as the file system owner, not as root. Our installation video shows the full run.
1. URLs and the admin path
--base-url is required and must include the scheme and a trailing slash. For HTTPS add --base-url-secure, --use-secure=1 and --use-secure-admin=1. --backend-frontname sets the admin URL; if you leave it out, Magento creates a random one and shows it at the end. Avoid plain words like “admin”.
2. Database
--db-host, --db-name, --db-user and --db-password point to an empty database you created before. --db-prefix adds a table prefix of up to five characters; most stores do not need it. --cleanup-database drops existing tables first, so use it only on a test install.
3. Admin user
To create the first admin during install, give all five: --admin-firstname, --admin-lastname, --admin-email, --admin-user and --admin-password. The password needs at least 7 characters with at least one letter and one number. Use a longer one and put it in single quotes.
4. Language, currency and time zone
--language (for example en_GB), --currency (GBP) and --timezone (Europe/London) set the defaults for the admin and the storefront. You can change them later in the admin. Add --use-rewrites=1 so URLs work without index.php.
5. OpenSearch
Set --search-engine=opensearch with --opensearch-host (default localhost) and --opensearch-port (default 9200). If your OpenSearch needs a login, add --opensearch-enable-auth=1, --opensearch-username and --opensearch-password. --opensearch-index-prefix (default magento2) keeps two stores on one OpenSearch apart.
6. Valkey for sessions and cache
In 2.4.9 Valkey replaced Redis in the CLI tooling. setup:install accepts the same options as setup:config:set, so you can set Valkey right away: --session-save=valkey, --cache-backend=valkey and --page-cache=valkey, each with its own server and database number. Adobe suggests database 0 for the default cache, 1 for the page cache and 2 for sessions; they must be different.
The full command
Replace the example values with your own:
bin/magento setup:install \
--base-url=https://shop.example.com/ \
--base-url-secure=https://shop.example.com/ \
--use-secure=1 --use-secure-admin=1 \
--backend-frontname=office_k7q2 \
--db-host=localhost --db-name=magento \
--db-user=magento --db-password='DbPass-2026' \
--admin-firstname=Jane --admin-lastname=Doe \
--admin-email=jane@example.com --admin-user=jane \
--admin-password='Change-me-2026' \
--language=en_GB --currency=GBP --timezone=Europe/London \
--use-rewrites=1 \
--search-engine=opensearch \
--opensearch-host=localhost --opensearch-port=9200 \
--session-save=valkey \
--session-save-valkey-host=127.0.0.1 --session-save-valkey-db=2 \
--cache-backend=valkey \
--cache-backend-valkey-server=127.0.0.1 --cache-backend-valkey-db=0 \
--page-cache=valkey \
--page-cache-valkey-server=127.0.0.1 --page-cache-valkey-db=1Next in the series: nginx for Magento: using nginx.conf.sample.
Want us to run the install for you?
We install Magento 2.4.9 with OpenSearch and Valkey, set it up for your store and keep it fast. See our managed Magento hosting, Magento installation and setup and speed optimization, or contact us below.

