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:

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

    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:

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

    For example,

    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:

    a2ensite <virtual host config file name>
    

    For example,

    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:

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

    For example,

    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
Previous pageApplication modes
Next pageProfiling

Commerce