Bootstrap parameters

This topic demonstrates how to set the values of Commerce application bootstrap parameters. See Overview of application initialization and bootstrapping.

The following table discusses the bootstrap parameters that you can set:

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

Set parameters using an environment variable

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

Set the application mode

You can specify 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:

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:

export MAGE_PROFILER=firebug
INFO
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.

Set parameters for Apache or Nginx

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

Nginx setting

See the Nginx sample configuration on GitHub.

Apache .htaccess setting

One way to set the application mode is by editing .htaccess. This way, you do not have to change Apache settings.

You can modify .htaccess in any of the following locations, depending on your entry point to the Commerce 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:

    code language-conf
    #   SetEnv MAGE_PROFILER firebug
    
  2. Set the value of MAGE_PROFILER to any of the following:

    code language-terminal
    firebug
    csvfile
    <custom value>
    
  3. Save your changes to .htaccess; you do not need to restart Apache for the change to take effect.

Apache setting

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

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

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

TIP
The following section assumes that you have already set up your virtual host. If you have not, consult a resource such as this DigitalOcean tutorial.

To Specify a bootstrap variable for Apache on Ubuntu:

  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:

    code language-conf
    SetEnv "<variable name>" "<variable value>"
    

    For example,

    code language-conf
    SetEnv "MAGE_PROFILER" "firebug"
    
  3. Save your changes and exit the text editor.

  4. Enable your virtual host if you have not already done so:

    code language-bash
    a2ensite <virtual host config file name>
    

    For example,

    code language-bash
    a2ensite my.magento.conf
    
  5. After setting the mode, restart the web server:

    • Ubuntu: service apache2 restart
    • CentOS: service httpd restart
TIP
This section assumes that you have already set up your virtual host. If you have not, consult a resource such as this DigitalOcean tutorial.

To specify a bootstrap variable for Apache on CentOS:

  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:

    code language-conf
    SetEnv "<variable name>" "<variable value>"
    

    For example,

    code language-conf
    SetEnv "MAGE_PROFILER" "firebug"
    
  3. Save your changes and exit the text editor.

  4. After setting the mode, restart the web server:

    • Ubuntu: service apache2 restart
    • CentOS: service httpd restart
recommendation-more-help
386822bd-e32c-40a8-81c2-ed90ad1e198c