How do I set Developer Mode in Magento 2
-
16-10-2019 - |
문제
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.
해결책
you can enable it from the cli
bin/magento deploy:mode:set developer
다른 팁
Another way, we can enable developer mode
- Goto
app/etc/
and openenv.php
- and change current application mode by
MAGE_MODE' => 'default'
toMAGE_MODE' => 'developer'
Then,please flush the cache
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.
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
Go to your magento root folder from command prompt and excecute below comand:
php bin/magento deploy:mode:set developer
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:
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
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.
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
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:
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/*
Set the mode:
magento deploy:mode:set developer
Following message will be displayed
Switched to developer mode.
make sure give permission
sudo chmod 777 . -R
after that
php bin/magento deploy:mode:set developer
otherwise permission denied