Enable and Disable Magento 2 Module

First Steps:

Ensure that you are login into the terminal using either as Magento file system owner (recommended) or as root user.
If you are not sile system ownser, you need to put “sudo” before every command.

Before doing the following commands, go to the Magento root Directory

cd <your Magento install dir>


Module enable:

To enable a module, run the following commands:

php bin/magento module:enable {ModuleName} php bin/magento setup:upgrade

a) Above the first command adds or enables your module {ModuleName} to the modules list.

b) Second command triggers setup scripts to install your Modules which are needed to setup.


Module Disable:

To enable a module, run the following command:

php bin/magento module:disable {ModuleName}


Module Uninstall:

To uninstall a module, run the following command:

php bin/magento module:uninstall {ModuleName}

This command executes the instillation, and deletes the module afterwards. Only the modules, installed through Composer, can be uninstalled in this way.


Deploy static view files:

After enabling, disabling or uninstalling a module, it’s better to deploy static content. Because, many modules have static files to be generated. To deploy, run the following commands:
Make sure there is no space around “/” before running following commands.

rm –rf var/cache/* rm –rf var/generation/* rm –rf var/page_cache/* rm –rf var/view_preprocessed/* rm –rf pub/static/adminhtml/* rm –rf pub/static/frontend/* rm –rf pub/static/_requirejs/* php bin/magento setup:static-content:deploy

a) First command cleans every folder from the var directory.

b) Second command cleans every folder from the pub/static directory.

c) Third command generates the static content with the new changes and new modules.

If you are logged as other user which is not Magento file system owner, then you need to have appropriate permissions to the above files and directories by running following commands:

sudo chown -R <magento file system owner>:<magento file system owner group> sudo chown -R :<magento file system owner group> .

Related Posts

Leave a Comment!

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

Let us know about your project!

We’d love to know more about your project and give estimation.