42

I'm trying to install Magento 2 but I am getting the following error:

Error happened during application run. Could not write error message to log. Please use developer mode to see the message.

I have tried adding SetEnv MAGE_MODE developer to .htaccess as advised by Alan Storm http://magento-quickies.alanstorm.com/post/58757471044/magento-2-developer-mode but no luck.

  • Are you using apache or nginx? How exactly did you set the environmental variable? – Foo Bar Jan 14 '14 at 15:20
  • @Tim I am using Apache. I set it by adding it to the top of the .htaccess – Paul Donnelly Jan 14 '14 at 15:28
  • Adding what? Please add all this info into your question. – Foo Bar Jan 14 '14 at 19:01
  • You will have to have mod_env enabled for Apache and AllowOverride On in your vhost configuration in order for .htaccess to be parsed. – benmarks Jan 14 '14 at 19:04

12 Answers 12

68

you can enable it from the cli

bin/magento deploy:mode:set developer

27

Another way, we can enable developer mode

  • Goto app/etc/ and open env.php
  • and change current application mode by MAGE_MODE' => 'default' to MAGE_MODE' => 'developer'

Then,please flush the cache

17

As you and others have noted:

SetEnv MAGE_MODE "developer"

in your .htaccess file should enable developer mode assuming that AllowOverride All is in the proper <Directory> directive.

Related to your original problem though, it might be due to a permissions issue where the Apache process user does not have write permissions to the right directories.

For a quick test, you can do the following inside your Magento 2 directory:

chmod -R a+wX var
chmod -R a+wX app/etc
chmod -R a+wX pub

Then if the installation wizard pops up, you can try to make sure you have the correct permissions for your Apache process on those directories.

7

Are you using mod_fastcgi + php-fpm? I ran into this issue as in that environment. The environment variable was getting prefixed with "REDIRECT_".

Related question on stack exchange here: Apache SetEnv prepends REDIRECT_ . What gives?

I was able to resolve this by just setting the environment variable in the php-fpm pool configuration file:

env[MAGE_MODE] = developer
7

In order to change magento 2.0 mode you have to run this command php bin/magento deploy:mode:set developer in CMD or your SSH windows into magento 2.0 root folder. More information you can find here and here.

5

Go to your magento root folder from command prompt and excecute below comand:

php bin/magento deploy:mode:set developer

4

If you're using the built-in web server in PHP 5.4 you need to set the ENV when starting up the server:

MAGE_MODE=developer php -d variables_order=EGPCS -S 127.0.0.1:8080 router.php

For more information on how to use PHP 5.4's built-in webserver, including setup of Magento 2 see this screencast:

http://quick.as/kkbahnlx

4

Hi I have read your question and please see solution.

You can set developer mode by CLI command and also manually

To set it manually:

open your magento 2 root directory, Open file "/app/etc/env.php" and search "'MAGE_MODE' =>". you can change magento mode here manually.

CLI command for production mode:

magento deploy:mode:set production

CLI command for developer mode:

magento deploy:mode:set developer

for more information please visit below URL. http://php-scripts-form.blogspot.nl/2017/09/magento-2-how-to-set-production-mode.html

  • How can I see the mode before changing it? – Razvan Zamfir Nov 22 '17 at 13:56
  • @RazvanZamfir you can use deploy:mode:show to see the current mode. – Eric Seastrand Dec 22 '17 at 20:36
3

Please try by adding the following line inside index.php at the beginning file.

$_SERVER['MAGE_MODE'] = 'developer';

Hope you will see the error message.

  • 4
    I would highly discourage to edit core files like the index.php – 7ochem May 20 '15 at 12:02
  • 1
    I believe this should be out of repo either way, so once you change it on local will not really do too much bad. – Maciej Paprocki Jun 14 '16 at 10:30
3

If you are using NginX as the web server... .htaccess won't affect. Changing the NginX Server Directives will enable the developer mode.

for example: /etc/nginx/sites-available/m2_test.conf (Assuming nginx is properly configured)

server {
   listen 80;
   server_name m2.test.com;
   set $MAGE_ROOT path/to/magento2;
   set $MAGE_MODE developer;
   include other/configurations/file.conf;
}

This set $MAGE_MODE will turn on the developer mode.

other/configurations/file.conf should link to the configurations file path which should be a copy of [MAGENTO_DOC_ROOT]/nginx.conf.sample

As others have mentioned, php bin/magento deploy:mode:set developer also will enable it

  • have i to set developer mode in both nginx conf and from magento console? What happens if one is developer and one production? – LucScu Sep 27 '16 at 9:38
3

When you change from production to developer mode, you should clear generated classes and Object Manager entities like proxies to prevent unexpected errors. After doing so, you can change modes. Use the following steps:

  1. If you’re changing from production mode to developer mode, delete the contents of the var/generation and var/di directories:

    rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/* 
    
  2. Set the mode:

    magento deploy:mode:set developer
    

Following message will be displayed

   Switched to developer mode.
0

make sure give permission

sudo chmod 777 . -R

after that

php bin/magento deploy:mode:set developer

otherwise permission denied

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.