Shared configuration

This example shows how to change the following settings in your development system, update the shared configuration file, config.php, in your build system, and implement the same settings in your production system:

  • Timezone
  • Weight unit

These settings are available in the Magento Admin in Stores > Settings > Configuration > General > General.

You can use the same procedure to configure any non-sensitive, non-system-specific settings in the following references:

Before you begin

Before you begin, set up file system permissions and ownership as discussed in Prerequisite for your development, build, and production systems.

Assumptions

This topic provides an example of modifying the production system configuration. You can choose different configuration options if you wish.

For the purposes of this example, we assume the following:

  • You use Git source control
  • The development system is available in a Git remote repository named mconfig
  • Your Git working branch is named m2.2_deploy

Step 1: Set the configuration in the development system

To set the timezone and weight units in your development system:

  1. Log in to the Magento Admin.
  2. Click Stores > Settings > Configuration > General > General.
  3. In the right pane, expand Locale Options.

    The following figure shows an example.

    Set locale options in the development system

  4. From the Timezone list, click GMT+00:00 (UTC).
  5. Clear the Use system value checkbox next to the Weight Unit field.
  6. From the Weight Unit list, click kgs.
  7. Click Save Config.
  8. If prompted, flush the Magento cache.

Step 2: Update the shared configuration

Generate the shared configuration file, app/etc/config.php, in your development system and transfer it using source control to your build system as discussed in this section.

  1. Log in to your development system as, or switch to, the Magento file system owner .

  2. Enter the following commands in the order shown:

    cd <Magento root dir>
    php bin/magento app:config:dump
    

    For example, if Magento is installed in /var/www/html/magento2, enter:

    cd /var/www/html/magento2
    php bin/magento app:config:dump
    
  3. If you use Git, enter the following command to confirm that app/etc/config.php was updated:

    git status
    

    You should see output similar to the following:

    On branch m2.2_deploy
    Changed but not updated:
      (use "git add &lt;file>..." to update what will be committed)
      (use "git checkout -- &lt;file>..." to discard changes in working directory)
           modified:   app/etc/config.php
    

    Do not submit changes to the generated, pub/media, or pub/static directories to source control. You’ll generate those files on your build system. The production system likely has code, themes, and so on that aren’t ready to use on production.

  4. Check in your changes to app/etc/config.php only to source control.

    The Git command follows:

    git add app/etc/config.php && git commit -m "Updated shared configuration" && git push mconfig m2.2_deploy
    

Step 3: Update your build system and generate files

Now that you’ve committed your changes to the shared configuration to source control, you can pull those changes in your build system, compile code, and generate static files. The last step is to pull those changes to your production system. As a result, your production system’s configuration will match your development system.

To update your build system:

  1. Log in to your build system as, or switch to, the Magento file system owner .
  2. Change to the build system’s Magento root directory.
  3. Pull the changes to app/etc/config.php from source control.

    The Git command follows:

    git pull mconfig m2.2_deploy
    
  4. Compile code:

    php bin/magento setup:di:compile
    
  5. After code has been compiled, generate static view files:

    php bin/magento setup:static-content:deploy -f
    
  6. Check the changes into source control.

    The Git command follows:

    git add -A && git commit -m "Updated files on build system" && git push mconfig m2.2_deploy
    

Step 4: Update the production system

The last step in the process is to update your production system from source control. This pulls all the changes you made on your development and build systems, which means your production system is completely up-to-date.

To update the production system:

  1. Log in to your production system as, or switch to, the Magento file system owner .
  2. Start maintenance mode:

    cd <Magento root dir>
    php bin/magento maintenance:enable
    

    For additional options, such as the ability to set an IP address whitelist, see magento maintenance:enable.

  3. If you use Magento Commerce, stop queue workers. TBD
  4. Pull code from source control.

    The Git command follows:

    git pull mconfig m2.2_deploy
    
  5. Update the configuration:

    php bin/magento app:config:import
    
  6. Clean the cache:

    php bin/magento cache:clean
    
  7. End maintenance mode:

    php bin/magento maintenance:disable
    

Verify the changes in the Magento Admin

To verify these settings are not editable in the Magento Admin:

  1. Log in to the Magento Admin.
  2. Click Stores > Settings > Configuration > General > General.
  3. In the right pane, expand Locale Options.

    The options you just set are displayed as follows:

    Configuration options not editable in the Admin

To change a setting that is locked in the Admin, use the magento config:set --lock command.