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 |
magento deploy:mode:set {mode}
command.This section discusses how to set the values of bootstrap parameters using environment variables.
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
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.
This section discusses how to specify the mode for either Apache or Nginx.
See the Nginx sample configuration on GitHub.
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:
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:
# SetEnv MAGE_PROFILER firebug
Set the value of MAGE_PROFILER
to any of the following:
firebug
csvfile
<custom value>
Save your changes to .htaccess
; you do not need to restart Apache for the change to take effect.
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.
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:
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
,
vim /etc/apache2/sites-available/my.magento.conf
vim /etc/apache2/sites-available/my.magento
Anywhere in the virtual host configuration, add the following line:
SetEnv "<variable name>" "<variable value>"
For example,
SetEnv "MAGE_PROFILER" "firebug"
Save your changes and exit the text editor.
Enable your virtual host if you have not already done so:
a2ensite <virtual host config file name>
For example,
a2ensite my.magento.conf
After setting the mode, restart the web server:
service apache2 restart
service httpd restart
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:
As a user with root
privileges, open /etc/httpd/conf/httpd.conf
in a text editor.
Anywhere in the virtual host configuration, add the following line:
SetEnv "<variable name>" "<variable value>"
For example,
SetEnv "MAGE_PROFILER" "firebug"
Save your changes and exit the text editor.
After setting the mode, restart the web server:
service apache2 restart
service httpd restart