Magento 2: Set Developer Mode and Production Mode via SSH

This short guide will help you to change/set developer mode and production mode in Magento 2 via command line interface (SSH command). Magento 2 has the following three primary modes,

  • Default Mode: When you initially set up a Magento 2 website it is typically in Default mode.
  • Developer Mode: When you develop or customize the Magento 2 website you should set the Magento 2 in developer mode.
  • Production Mode: When your Magento 2 store is ready to go to the production server, you should set the Magento 2 in production mode.

Click here for more details about Magento 2 modes.

Display Current Mode:

Run the below SSH command in your Magento 2 installed root directory to display current mode,

php bin/magento deploy:mode:show

It will return the result as below,

Current application mode: default. (Note: Environment variables may override this value.)

Set Developer Mode:

Run the below SSH command in your Magento 2 installed root directory to set/change developer mode,

php bin/magento deploy:mode:set developer

When you change from production mode to developer mode, you should clear generated classes and object manager entities 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 <Magento 2 installed dir>/generated/ and <Magento 2 installed dir>/var/di directories use the below command,

rm -rf <Magento 2 installed dir>/var/di/* <Magento 2 installed dir>/generated/*

Then run the below command to change from production mode to developer mode,

bin/magento deploy:mode:set developer

Set Production Mode:

Run the below SSH command in your Magento 2 installed root directory to set/change production mode,

php bin/magento deploy:mode:set production

Whenever the mode is changed from developer to production or vice versa, the contents of the following directories are cleared out,

  • var/cache
  • var/di
  • var/view_preprocessed
  • generated
  • pub/static

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *