1

I am using Nginx with 2 websites on. The first Server Config I have is:

server {
   listen 80;
   server_name "sh.dev";
   access_log /var/log/nginx/sh-access.log;
   error_log /var/log/nginx/sh-error.log;
   include /var/www/sh/project/nginx.conf;
   set $MAGE_ROOT "/var/www/sh/project";
   set $MAGE_MODE "developer";
}

upstream fastcgi_backend {
   server unix:/var/run/php/php7.0-fpm.sock;
}

And it is in developer mode, the second site uses a direct name for upstream:

server {
   listen 80;
   server_name "magento2.dev";
   access_log /var/log/nginx/magento2-access.log;
   error_log /var/log/nginx/magento2-error.log;
   include /var/www/magento2-test/magento2/nginx.conf.sample;
   set $MAGE_ROOT "/var/www/magento2-test/magento2";
   set $MAGE_MODE "developer";
}

upstream fast_backend {
   server unix:/var/run/php/php7.0-fpm.sock;
}

But I had to manually change the mode with:

bin/magento deploy:mode:set developer

Then if you throw an exception is Magento/Framework/App/Bootstrap.php:

public function run(AppInterface $application)
{

   throw new Exception('Break this thing');

    try {
        try {
            \Magento\Framework\Profiler::start('magento');
            $this->initErrorHandler();
            $this->initObjectManager();
            $this->assertMaintenance();
            $this->assertInstalled();
            $response = $application->launch();
            $response->sendResponse();
            \Magento\Framework\Profiler::stop('magento');
        } catch (\Exception $e) {
            \Magento\Framework\Profiler::stop('magento');
            if (!$application->catchException($this, $e)) {
                throw $e;
            }
        }
    } catch (\Exception $e) {
        $this->terminate($e);
    }
}

It should show the error on the front, but it does not.

1

Depends on whether you're using FPM or FastCGI.

For FPM: env[MAGE_MODE] = developer

For FastCGI: fastcgi_param MAGE_MODE developer;

I'm not very experienced with NGINX, so let me know how you get on.

1

Magento 2 GitHub repo provides some useful examples for that kind of setup.

For instance there is a nginx.conf.sample file where you can find the following:

set $MAGE_MODE default; # or production or developer
fastcgi_param MAGE_MODE $MAGE_MODE;

As well as the .htaccess file with the following code:

SetEnv MAGE_MODE developer

Please note that it is not recommended to set the modes on a server level and it's a better practice to use the CLI to do that:

php bin/magento deploy:mode:set developer|production
0

Developer mode is set in app/etc/env.php under the 'MAGE_MODE' key. This value is modified when you run bin/magento deploy:mode:set developer. I don't believe this can be set using server configuration.

See the documentation from Magento for more details - http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-mode.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.