Adobe Commerce 2.3 reached end of support in September 2022.

Set the value of bootstrap parameters

Overview of setting bootstrap parameter values

This topic discusses how to set the values of Magento application bootstrap parameters. More information about Magento application bootstrapping.

The following table discusses the bootstrap parameters you can set:

Bootstrap parameter Description
MAGE_DIRS Specifies custom directory and URL paths
MAGE_PROFILER Enables dependency graphs and HTML profiling
  • Not all bootstrap parameters are documented at this time.
  • You now set the Magento mode (developer, default, production) using the magento deploy:mode:set {mode} command.

Specifying a parameter value using an environment variable

This section discusses how to set the values of bootstrap parameters using environment variables.

Set the mode using an environment variable

You can specify Magento bootstrap variables as system-wide environment variables, which enables all processes to use them.

For example, you can use the MAGE_PROFILER system environment variable to specify a mode as follows:

1
MAGE_PROFILER={firebug|csv|<custom value>}

Set the variable using a shell-specific command. Because shells have differing syntax, consult a reference like unix.stackexchange.com.

Bash shell example for CentOS:

1
export MAGE_PROFILER=firebug

If a PHP Fatal error displays in the browser after you set a profiler value, restart your web server. The reason might be related to PHP bytecode caching, which caches bytecodes and PHP classpaths.

Specifying a parameter value

This section discusses how to specify the mode for either Apache or nginx.

See one of the following sections for more information:

Specify a variable using an nginx setting

See the nginx sample configuration on GitHub.

Specify a variable using .htaccess (Apache only)

One way to set the Magento mode is by editing .htaccess. This way, you don’t have to change Apache settings.

You can modify .htaccess in any of the following locations, depending on your entry point to the Magento application:

  • <magento_root>/.htaccess
  • <magento_root>/pub/.htaccess

To set a variable:

  1. Open any of the preceding files in a text editor and either add or uncomment the desired setting.

    For example, to specify a mode, uncomment the following:

    1
    
    #   SetEnv MAGE_PROFILER firebug
    
  2. Set the value of MAGE_PROFILER to any of the following:

    1
    2
    3
    
    firebug
    csvfile
    <custom value>
    
  3. Save your changes to .htaccess; you don’t need to restart Apache for the change to take effect.

Specify a variable using an Apache setting

The Apache web server supports setting the Magento mode using mod_env directives.

The Apache mod_env directive is slightly different in version 2.2 and version 2.4.

The procedures that follows show how to set the Magento mode in an Apache virtual host. This is not the only way to use mod_env directives; consult the Apache documentation for details.

Specify a bootstrap variable for Apache on Ubuntu

This section assumes you’ve already set up your virtual host. If you have not, consult a resource such as this DigitalOcean tutorial.

To set a Magento bootstrap variable using your web server’s environment:

  1. As a user with root privileges, open your virtual host configuration file in a text editor.

    For example, if your virtual host is named my.magento,

    • Apache 2.4: vim /etc/apache2/sites-available/my.magento.conf
    • Apache 2.2: vim /etc/apache2/sites-available/my.magento
  2. Anywhere in the virtual host configuration, add the following line:

    1
    
    SetEnv "<variable name>" "<variable value>"
    

    For example,

    1
    
    SetEnv "MAGE_PROFILER" "firebug"
    
  3. Save your changes and exit the text editor.
  4. Enable your virtual host if you haven’t already done so:

    1
    
    a2ensite <virtual host config file name>
    

    For example,

    1
    
    a2ensite my.magento.conf
    
  5. Restart the web server:

    • Ubuntu: service apache2 restart
    • CentOS: service httpd restart

Specify a bootstrap variable for Apache on CentOS

This section assumes you’ve already set up your virtual host. If you have not, consult a resource such as this DigitalOcean tutorial.

To set a Magento bootstrap variable using your web server’s environment:

  1. As a user with root privileges, open /etc/httpd/conf/httpd.conf in a text editor.

  2. Anywhere in the virtual host configuration, add the following line:

    1
    
    SetEnv "<variable name>" "<variable value>"
    

    For example,

    1
    
    SetEnv "MAGE_PROFILER" "firebug"
    
  3. Save your changes and exit the text editor.

After setting the mode, restart the web server:

  • Ubuntu: service apache2 restart
  • CentOS: service httpd restart

Related topics