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.
Best Answer
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.