The process of installing Magento Commerce is similar to installation of Magento Open Source, with a few key differences. The metapackage used to install Magento Commerce is different from the one for Magento Open Source. You also have the option to use a split database system with three master databases.
Using a split database system for product data, checkout, and orders provides the ability to scale each one independently to handle increased loads. This feature is unique to the self-hosted Magento Commerce and isn’t available with Magento Open Source or Magento Commerce Cloud.
Although you can install Magento Commerce by downloading an archive file from your Magento account, using Composer is more efficient and will give you early access to new patches two weeks before the general public.
Step 1: Pre-install checks
Before installing Magento Commerce 2.4.x, verify that you have the following:
- A server with SMTP capabilities that meets Magento’s requirements.
- A separate user for Magento without superuser privileges.
- A subscription to the Magento Commerce software.
- Composer version 1.10.x.
- Authentication keys from your Magento account.
- (Optional, only if you wish to use a split database system) Three databases: magento, magento_quote, magento_sales.
Step 2: Download the Magento Commerce metapackage
To install Magento Commerce on your server, download the metapackage using Composer from the Magento code repository by running the following command in your terminal. Please note that the directory you specify below must be empty:
$ composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition <install-directory-name>
If you’d like to download a specific version of Magento Commerce, you can update ‘magento/project-enterprise-edition’ to ‘magento/project-enterprise-edition=<version>’.
For example, to request the metapackage for Magento Commerce 2.4.1, you would run the following command in the terminal:
$ composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.4.1 <install-directory-name>
Replace <install-directory-name> with the actual location like /var/www/magento or replace it with a ‘.’ if you’re in the destination directory.
Next, you will be asked to enter the Magento authentication keys from your Magento account to access the metapackage.
Once entered, Composer will download the metapackage in about 5–10 minutes.
Step 3: Install Magento Commerce
Presuming you have the database set up, copy and paste the following commands in your terminal to install Magento Commerce:
bin/magento setup:install \
--base-url=http://example.com \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1
Here you can find detailed descriptions of all available Magento Commerce installation options.
You must use secure credentials and replace all values in the above code with those applicable for your store before pasting it into the terminal.
After the installation is completed, you will receive a confirmation message in the terminal along with an auto-generated URL to the admin panel. An email will be sent to the email address specified after ‘--admin-email=’. This link is required to set up two-factor authentication before you can access the admin panel.
Step 4: Set file permissions
After the download completes, set correct file permissions for the web server group to allow it to write the files necessary during the installation. Run the following commands in the terminal within the Magento directory:
$ find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
$ find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
$ chown -R :www-data .
$ chmod u+x bin/magento
Step 5: Set up a cron job
Magento requires cron to run scheduled background tasks like indexation. You must configure it before setting up your store. To setup cron, run the following command in the terminal:
$ bin/magento cron:install
To verify cron is set up, run the following command:
$ crontab -l
Step 6: Verify the installation
To verify your store is live and working, access your website using a web browser. After this, you can set up 2FA and log into the admin panel using the link received via email.
Step 7: (Optional) Set up split databases
This is an optional step as you can use Magento Commerce on a single database if required. Should you wish to set up split databases, doing so before using your store in a production environment is strongly recommended.
Make sure you’re logged in as the Magento filesystem owner and are in the root directory of your Magento installation. Run the following commands in the terminal:
bin/magento setup:db-schema:split-quote --host="<checkout db host or ip>" --dbname="<name>" --username="<checkout db username>" --password="<password>"
bin/magento setup:db-schema:split-sales --host="<checkout db host or ip>" --dbname="<name>" --username="<checkout db username>" --password="<password>"
Replace the values inside the double quotes with those applicable for your store.
Congratulations, you’ve successfully installed Magento Commerce on your server and are now ready to set up the rest of your store.