Below we are going to describe how to add install Magento 2 extension in two ways: manually or via composer

Prior to installation, you may want to:

  1. Back up your database and files.
  2. Enable maintenance mode: bin/magento maintenance:enable

We strongly recommend to test extensions on staging environment before installing it on your live store.

1. Manual Magento 2 Extension Installation

1. Download extension archive and extract files.

2. Upload extension files to your Magento folder. If the first folder in extension archive is app then you simply need to upload it to the root of your Magento folder. But if you downloaded extension from github, for example, then you will most likely have only one folder (usually with wrong name) with extension files inside. In this case you need to create correct folder structure first. The final path to extension files in your Magento folder should look like this:

app/code/ExtensionVendor/ExtensionName

You can check extension and vendor name in registration.php in the root of the extension folder:

 ComponentRegistrar::register(
    ComponentRegistrar::MODULE,
    'Olegnax_DeferJS',
    __DIR__
); 

From the example above you can see that the vendor name is Olegnax and extension name is DeferJS. So the path to extension files should be: app/code/Olegnax/DeferJS

3. Make sure that extension files has correct owner: Overview of ownership and permissions.

4. Now you need to login to register extension and recompile Magento project. Log in to your server with SSH, go to Magento 2 folder and run following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy  

5. That’s it. Now your extension should be installed and enabled.

2. How to install Magento 2 Extension via Composer

To install Magento 2 extensions via Composer you should have SSH access and Composer installed on your server.

1. Log in to your server with SSH and navigate to your Magento folder.

2. Use following command to get the latest version of extension:

 composer require vendor/module-name

Replace vendor and module-name with actual extension vendor and module name. I.e.:

 composer require olegnax/module-core

You can check its name in composer.json that can be found inside of the extension folder. The line with name is what you need i.e.:

...
   "name": "olegnax/module-core",
   "description": "Olegnax Core",
   "version": "1.0.9.1",
...

You can also download specific extension version by adding version number after the module name, like this:

 composer require olegnax/module-core:1.0.9 

3. Enter authentication keys if requested. You can get them on Magento Marketplace

4. Now you need to register extension and recompile Magento project using following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy  

5. That’s it. Now your extension should be installed and enabled.

3. Verify the extension

You can check if extension is installed and enabled using following command:

  bin/magento module:status 

You should see extension in the list:

Otherwise enable disabled extensions, e.g.:

php bin/magento mo:e Olegnax_Core Olegnax_GoogleMap

and re-run commands from p.4:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

Disable maintenance mode if you enabled it: bin/magento maintenance:disable