Extensions help you add functionality to your Magento 2 store. Although Magento has features such as catalog management and tools for advertising, third-party extensions make it easy to offer a unique shopping experience.
You can install a third-party extension via Composer or using a ZIP file. This tutorial will show you how to install an extension using a .zip archive file.
- Back up your server to avoid data loss in case the installation fails.
- Download the extension package from where you’ve purchased the extension.
- Set pre-installation file permissions.
- Enable developer mode using the following command:
php bin/magento deploy:mode:set developer
Note: It’s best to install and test a new extension in a development environment before doing it on your live store.
Enable Maintenance Mode
Enabling maintenance mode temporarily restricts visitors from accessing your website while you install the extension.
Use the following command to enable maintenance mode:
php bin/magento maintenance:enable
Upload Files to the Server
Log in to your Magento 2 server using an SSH client. Then upload the extension file to a folder inside your home directory.
Extract Contents of the .zip File
Extract the .zip archive file into a separate folder but the same directory using the following command:
unzip archive.zip -d module-dir
Here, we’ve used “archive.zip” as a placeholder for the extension ZIP file name. Similarly, “module-dir” is a placeholder for the destination directory where the contents of the .zip archive file will be extracted. The path of this new directory will be “/home/data/module-dir/.”
Check .zip File Contents
Once the package is extracted, it’s time to check the contents of the .zip folder. You may see folders like “Block”, “Controller”, and “etc.: inside “vendor/module” directory.
Here, “vendor” is the name of the extension vendor, and “module” is the name of the extension module.
Copy the Extension Files
Copy the required files in the “magento-project-root/app/code” folder of the Magento root directory.
If you don’t see the app/code folder, which might be the case if it’s your first time installing an extension using this method, you’ll need to create it manually.
To create the code folder, run the following command from the Magento project root:
Then copy the extension files you extracted in the home directory into the app/code folder in the Magento file system using the following command:
cp -R /home-dir/data/module-dir/* app/code
Note: Run this command from the Magento project root.
Complete the Installation
Install the Magento 2 extension, compile the code, and deploy static view files using the following commands in the command line:
Check Status of the Extension
To verify your extension is installed, run the following command:
bin/magento module:status VendorName_ComponentName
You should receive the following output stating that the extension is enabled.
The following module is enabled:
To make sure that the enabled modules are properly registered, run ‘setup:upgrade’.
Cache cleared successfully.
Generated classes cleared successfully. Please run the ‘setup:di:compile’ command to generate classes.
Generated static view files cleared successfully.
Clear Magento Cache
Now, clear the Magento cache using the following command:
Check File Permissions
Remove the write permission from essential directories. It stops users from creating or deleting critical extension directories.
Disable Maintenance Mode
Disable maintenance mode using this command:
This command allows the front end of the website to be available again.
You’ve now successfully installed a Magento extension from a ZIP file. You can confirm the installation from the Magento admin panel.