Adobe Commerce 2.3 reached end of support in September 2022.

Deployment flow

The Magento production deployment flow helps a store reach maximum performance.

Install dependencies

The composer.json and composer.lock files manage Magento dependencies and install the appropriate version for each package. You must install dependencies before preprocessing dependency injection instructions if you plan to update the autoloader.

To install Magento dependencies:

1
composer install --no-dev

Preprocess dependency injection instructions

When you preprocess and compile dependency injection (DI) instructions, Magento:

  • Reads and processes all present configuration
  • Analyzes dependencies between classes
  • Creates autogenerated files (including proxies, factories, etc.)
  • Stores compiled data and configuration in a cache that saves up to 25% of time on requests processing

To preprocess and compile DI instructions:

1
bin/magento setup:di:compile

Update the autoloader

After compilation completes, confirm that APCu is enabled and update the autoloader:

To update the autoloader:

The -o option converts PSR-0/4 autoloading to classmap to get a faster autoloader. The --apcu option uses APCu to cache found/not-found classes.

1
composer dump-autoload -o --apcu

If you plan on updating the autoloader, you must run the following commands in order:

1
composer install --no-dev
1
bin/magento setup:di:compile
1
composer dump-autoload -o
1
bin/magento setup:static-content:deploy

Deploy static content

Deploying static content causes Magento 2 to perform the following actions:

  • Analyze all static resources
  • Perform merge, minimization, and bundling of content
  • Read and process theme data
  • Analyze theme fallback
  • Store all processed and materialized content to specific folder for further usage

If your static content is not deployed, Magento performs all listed operation on the fly, leading to a significant increase in response time.

You can use a variety of options to customize deployment operations based on store size and fulfillment needs. The most common is the compact deploy strategy. See Static files deployment strategies

To deploy static content:

1
bin/magento setup:static-content:deploy

This command allows Composer to rebuild the mapping to project files so that they load faster.

Set production mode

Setting the mode to production automatically runs setup:di:compile and setup:static-content:deploy.

Finally, you need to place your store in Production mode. Production mode is specifically optimized for maximum performance of your store. It also de-activates all developer-specific features. This can be done in your .htaccess or nginx.conf file:

SetEnv MAGE_MODE production

You can also deploy static content, compile the content, and set the mode in one CLI command:

1
bin/magento deploy:mode:set production

The command runs in the background and does not allow you to set additional options on each specific step.

Additional pre-launch actions

These steps are recommended, but are not mandatory. You can perform them immediately before launching your store in production mode. The list includes:

  • Re-index data to avoid the presence of any inconsistent data in your indexes.
  • Flush the cache to be sure no old or incorrect data are left in cache.
  • Warm up the cache, which calls out the most popular or critical store pages in advance, so the cache for them is generated and stored. This operation can be performed with any internet crawler or manually, if you have a small store.