Learn how to handle the file permission in Magento 2 with shared hosting in the Developer mode and Production Mode in Magento 2.
Magento 2 hosting, commonly has two types: Shared hosting and Private hosting. Here in this, we will talk about shared hosting.
Build your Amazon-like multi-vendor marketplace website @ $249/- now!!!
Get your free live demo now: Click here
Usually, shared hosting offers to allow you to log in to the server as one user. The user may log in, then they may transfer files using FTP, and this user also runs the web server.
How to handle the file permission in Magento 2?
Set up one user for default or developer mode
The below-mentioned directories should be writable by the user in default or developer mode to give file permission in Magento 2:
By your shared hosting provider, you may set this file permission in Magento 2 using the command line or a file manager application offered.
Set up one user for production mode
You must remove write access from files in the following directories for improved security When you’re set to organize your site for production mode:
To update an element, install new components, or upgrade Magento software, all the previous directories should be read-write
To eliminate writable permissions to files and directories from the web server user’s group
- You may log in to your Magento server.
- Then you may modify your Magento installation directory.
- You may enter the following command to modify to production mode:
- php bin/magento deploy:mode:set production
- You may type the following commands:
- Get var vendor pub/static app/etc var/generation var/di var/view_preprocessed -type f -exec chmod u-w {} \;
- find var vendor pub/static app/etc var/generation var/di var/view_preprocessed -type d -exec chmod u-w {} \;
- chmod o-rwx app/etc/env.php
- chmod u+x bin/magento
You may alternately type all the previous commands as one command:
Find pub/static app/etc var/generation var/di var/view_preprocessed -type f -exec chmod u-w {} \; && find pub/static app/etc var/generation var/di var/view_preprocessed -type d -exec chmod u-w {} \; && chmod o-rwx app/etc/env.php && chmod u+x bin/magento
Create files and directories writable:
To create the files and directories writable, so you can update components and upgrade the Magento 2 software:
- Log in to your Magento server.
- Modify to your Magento installation directory.
- Type the following commands
- chmod -R u+w
Looking to build a Magento 2 store? get started today!!!
Related:
Leave a Reply